Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-09-11 08:42:14
Exec Total Coverage
Lines: 8343 12100 69.0%
Functions: 93 127 73.2%
Branches: 5466 10261 53.3%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/util.h"
3 #include "base/zapp.h"
4 #include "base/qrs.h"
5 #include "base/cpool.h"
6 #include "base/packfile.h"
7 #include "base/dmap.h"
8 #include "base/combo.h"
9 #include "base/msgstr.h"
10 #include <filesystem>
11 #include <stdio.h>
12 #include <cstring>
13 #include <string>
14 #include <map>
15 #include <vector>
16 #include <assert.h>
17 #include <fmt/format.h>
18
19
20 #include "metadata/sigs/devsig.h.sig"
21 #include "metadata/sigs/compilersig.h.sig"
22 #include "metadata/versionsig.h"
23 #include "base/zc_alleg.h"
24 #include "base/zdefs.h"
25 #include "base/colors.h"
26 #include "tiles.h"
27 #include "base/zsys.h"
28 #include "qst.h"
29 #include "defdata.h"
30 #include "subscr.h"
31 #include "font.h"
32 #include "zc/replay.h"
33 #include "zc/zc_custom.h"
34 #include "sfx.h"
35 #include "md5.h"
36 #include "zinfo.h"
37 #include "zc/ffscript.h"
38 #include "particles.h"
39 #include "dialog/alert.h"
40 #include "base/misctypes.h"
41
42 #ifdef __EMSCRIPTEN__
43 #include "base/emscripten_utils.h"
44 #endif
45
46 //FFScript FFCore;
47 extern FFScript FFCore;
48 extern ZModule zcm;
49 extern zcmodule moduledata;
50 extern uint8_t __isZQuest;
51 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
52 extern particle_list particles;
53 extern void setZScriptVersion(int32_t s_version);
54 //FFSCript FFEngine;
55
56 int32_t temp_ffscript_version = 0;
57 static bool read_ext_zinfo = false, read_zinfo = false;
58 static bool loadquest_report = false;
59 static char const* loading_qst_name = NULL;
60 static byte loading_qst_num = 0;
61
62 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
63 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
64
65 #ifdef _MSC_VER
66 #define strncasecmp _strnicmp
67 #endif
68
69 #ifndef _AL_MALLOC
70 #define _AL_MALLOC(a) _al_malloc(a)
71 #define _AL_FREE(a) _al_free(a)
72 #endif
73
74 using std::string;
75 using std::pair;
76
77 // extern bool debug;
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern zcmap *ZCMaps;
80 extern byte *colordata;
81 //extern byte *tilebuf;
82 extern tiledata *newtilebuf;
83 extern byte *trashbuf;
84 extern itemdata *itemsbuf;
85 extern wpndata *wpnsbuf;
86 extern comboclass *combo_class_buf;
87 extern guydata *guysbuf;
88 extern ZCHEATS zcheats;
89 extern zinitdata zinit;
90 extern char palnames[MAXLEVELS][17];
91 extern int32_t memrequested;
92 extern char *byte_conversion(int32_t number, int32_t format);
93 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
94 string zScript;
95 115 std::map<int32_t, script_slot_data > ffcmap;
96 115 std::map<int32_t, script_slot_data > globalmap;
97 115 std::map<int32_t, script_slot_data > genericmap;
98 115 std::map<int32_t, script_slot_data > itemmap;
99 115 std::map<int32_t, script_slot_data > npcmap;
100 115 std::map<int32_t, script_slot_data > ewpnmap;
101 115 std::map<int32_t, script_slot_data > lwpnmap;
102 115 std::map<int32_t, script_slot_data > playermap;
103 115 std::map<int32_t, script_slot_data > dmapmap;
104 115 std::map<int32_t, script_slot_data > screenmap;
105 115 std::map<int32_t, script_slot_data > itemspritemap;
106 115 std::map<int32_t, script_slot_data > comboscriptmap;
107 115 std::map<int32_t, script_slot_data > subscreenmap;
108 void free_newtilebuf();
109 bool combosread=false;
110 bool mapsread=false;
111 bool fixffcs=false;
112 bool fixpolsvoice=false;
113
114 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
115 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
116 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
117 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
118
119 char qstdat_string[2048] = { 0 };
120
121 static zinfo* load_tmp_zi = NULL;
122
123 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
124 const byte clavio[9]={97,109,111,110,103,117,115,0};
125
126 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
127 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
128
129 const char *qst_error[] =
130 {
131 "OK","File not found","Invalid quest file",
132 "Version not supported","Obsolete version",
133 "Missing new data" , /* but let it pass in ZQuest */
134 "Internal error occurred", "Invalid password",
135 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
136 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
137 };
138
139 //for legacy quests -DD
140 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
141 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
142 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
143 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
144 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
145 };
146
147 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
148
149
150 void delete_combo_aliases()
151 {
152 for(int32_t j(0); j<256; j++)
153 {
154 if(combo_aliases[j].combos != NULL)
155 {
156 delete[] combo_aliases[j].combos;
157 combo_aliases[j].combos=NULL;
158 }
159
160 if(combo_aliases[j].csets != NULL)
161 {
162 delete[] combo_aliases[j].csets;
163 combo_aliases[j].csets=NULL;
164 }
165 }
166
167 }
168
169 char *byte_conversion(int32_t number, int32_t format)
170 {
171 static char num_str[40];
172
173 if(format==-1) //auto
174 {
175 format=1; //bytes
176
177 if(number>1024)
178 {
179 format=2; //kilobytes
180 }
181
182 if(number>1024*1024)
183 {
184 format=3; //megabytes
185 }
186
187 if(number>1024*1024*1024)
188 {
189 format=4; //gigabytes (dude, what are you doing?)
190 }
191 }
192
193 switch(format)
194 {
195 case 1: //bytes
196 sprintf(num_str,"%db",number);
197 break;
198
199 case 2: //kilobytes
200 sprintf(num_str,"%.2fk",float(number)/1024);
201 break;
202
203 case 3: //megabytes
204 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
205 break;
206
207 case 4: //gigabytes
208 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
209 break;
210
211 default:
212 abort();
213 break;
214 }
215
216 return num_str;
217 }
218
219 1610 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
220 {
221 static char num_str1[40];
222 static char num_str2[40];
223 static char num_str[80];
224
225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1610 times.
1610 if(format1==-1) //auto
226 {
227 1610 format1=1; //bytes
228
229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1610 times.
1610 if(number1>1024)
230 {
231 1610 format1=2; //kilobytes
232 1610 }
233
234
2/2
✓ Branch 0 taken 1150 times.
✓ Branch 1 taken 460 times.
1610 if(number1>1024*1024)
235 {
236 460 format1=3; //megabytes
237 460 }
238
239
1/2
✓ Branch 0 taken 1610 times.
✗ Branch 1 not taken.
1610 if(number1>1024*1024*1024)
240 {
241 format1=4; //gigabytes (dude, what are you doing?)
242 }
243 1610 }
244
245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1610 times.
1610 if(format2==-1) //auto
246 {
247 1610 format2=1; //bytes
248
249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1610 times.
1610 if(number2>1024)
250 {
251 1610 format2=2; //kilobytes
252 1610 }
253
254
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1495 times.
1610 if(number2>1024*1024)
255 {
256 1495 format2=3; //megabytes
257 1495 }
258
259
1/2
✓ Branch 0 taken 1610 times.
✗ Branch 1 not taken.
1610 if(number2>1024*1024*1024)
260 {
261 format2=4; //gigabytes (dude, what are you doing?)
262 }
263 1610 }
264
265
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 1150 times.
✓ Branch 3 taken 460 times.
✗ Branch 4 not taken.
1610 switch(format1)
266 {
267 case 1: //bytes
268 sprintf(num_str1,"%db",number1);
269 break;
270
271 case 2: //kilobytes
272 1150 sprintf(num_str1,"%.2fk",float(number1)/1024);
273 1150 break;
274
275 case 3: //megabytes
276 460 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
277 460 break;
278
279 case 4: //gigabytes
280 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
281 break;
282
283 default:
284 abort();
285 break;
286 }
287
288
2/5
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1495 times.
✗ Branch 4 not taken.
1610 switch(format2)
289 {
290 case 1: //bytes
291 sprintf(num_str2,"%db",number2);
292 break;
293
294 case 2: //kilobytes
295 115 sprintf(num_str2,"%.2fk",float(number2)/1024);
296 115 break;
297
298 case 3: //megabytes
299 1495 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
300 1495 break;
301
302 case 4: //gigabytes
303 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
304 break;
305
306 default:
307 abort();
308 break;
309 }
310
311 1610 sprintf(num_str, "%s/%s", num_str1, num_str2);
312 1610 return num_str;
313 }
314
315 char *ordinal(int32_t num)
316 {
317 static const char *ending[4] = {"st","nd","rd","th"};
318 static char ord_str[8];
319
320 char *end;
321 int32_t t=(num%100)/10;
322 int32_t n=num%10;
323
324 if(n>=1 && n<4 && t!=1)
325 end = (char *)ending[n-1];
326 else
327 end = (char *)ending[3];
328
329 sprintf(ord_str,"%d%s",num%10000,end);
330 return ord_str;
331 }
332
333 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
334 {
335 int32_t ret;
336 *version=0;
337 *build=0;
338 byte temp_map_count=map_count;
339 byte temp_midi_flags[MIDIFLAGS_SIZE];
340 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
341
342 zquestheader tempheader;
343
344 if(!f)
345 {
346 return qe_invalid;
347 }
348
349 ret=readheader(f, &tempheader);
350
351 if(ret)
352 {
353 return ret;
354 }
355
356 map_count=temp_map_count;
357 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
358 *version=tempheader.zelda_version;
359 *build=tempheader.build;
360 return 0;
361 }
362
363
364 bool find_section(PACKFILE *f, int32_t section_id_requested)
365 {
366
367 if(!f)
368 {
369 return false;
370 }
371
372 int32_t section_id_read;
373 bool catchup=false;
374 word dummy;
375 byte tempbyte;
376 char tempbuf[65536];
377
378
379 switch(section_id_requested)
380 {
381 case ID_RULES:
382 case ID_STRINGS:
383 case ID_MISC:
384 case ID_TILES:
385 case ID_COMBOS:
386 case ID_CSETS:
387 case ID_MAPS:
388 case ID_DMAPS:
389 case ID_DOORS:
390 case ID_ITEMS:
391 case ID_WEAPONS:
392 case ID_COLORS:
393 case ID_ICONS:
394 case ID_INITDATA:
395 case ID_GUYS:
396 case ID_MIDIS:
397 case ID_CHEATS:
398 break;
399
400 default:
401 al_trace("Bad section requested!\n");
402 return false;
403 break;
404 }
405
406 dword section_size;
407
408 //section id
409 if(!p_mgetl(&section_id_read,f))
410 {
411 return false;
412 }
413
414 while(!pack_feof(f))
415 {
416 switch(section_id_read)
417 {
418 case ID_RULES:
419 case ID_STRINGS:
420 case ID_MISC:
421 case ID_TILES:
422 case ID_COMBOS:
423 case ID_CSETS:
424 case ID_MAPS:
425 case ID_DMAPS:
426 case ID_DOORS:
427 case ID_ITEMS:
428 case ID_WEAPONS:
429 case ID_COLORS:
430 case ID_ICONS:
431 case ID_INITDATA:
432 case ID_GUYS:
433 case ID_MIDIS:
434 case ID_CHEATS:
435 catchup=false;
436 break;
437
438 default:
439 break;
440 }
441
442
443 while(catchup)
444 {
445 //section id
446 section_id_read=(section_id_read<<8);
447
448 if(!p_getc(&tempbyte,f))
449 {
450 return false;
451 }
452
453 section_id_read+=tempbyte;
454 }
455
456 if(section_id_read==section_id_requested)
457 {
458 return true;
459 }
460 else
461 {
462 //section version info
463 if(!p_igetw(&dummy,f))
464 {
465 return false;
466 }
467
468 if(!p_igetw(&dummy,f))
469 {
470 return false;
471 }
472
473 //section size
474 if(!p_igetl(&section_size,f))
475 {
476 return false;
477 }
478
479 //pack_fseek(f, section_size);
480 while(section_size>65535)
481 {
482 pfread(tempbuf,65535,f);
483 tempbuf[65535]=0;
484 section_size-=65535;
485 }
486
487 if(section_size>0)
488 {
489 pfread(tempbuf,section_size,f);
490 tempbuf[section_size]=0;
491 }
492 }
493
494 //section id
495 if(!p_mgetl(&section_id_read,f))
496 {
497 return false;
498 }
499 }
500
501 return false;
502 }
503
504
505
506
507
508 bool valid_zqt(PACKFILE *f)
509 {
510
511 //word tiles_used;
512 //word combos_used;
513 //open the file
514 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
515 if(!f)
516 return false;
517
518 //for now, everything else is valid
519 return true;
520
521 /*int16_t version;
522 byte build;
523
524 //read the version and make sure it worked
525 if(!p_igetw(&version,f))
526 {
527 goto error;
528 }
529
530 //read the build and make sure it worked
531 if(!p_getc(&build,f))
532 goto error;
533
534 //read the tile info and make sure it worked
535 if(!p_igetw(&tiles_used,f))
536 {
537 goto error;
538 }
539
540 for (int32_t i=0; i<tiles_used; i++)
541 {
542 if(!pfread(trashbuf,tilesize(tf4Bit),f))
543 {
544 goto error;
545 }
546 }
547
548 //read the combo info and make sure it worked
549 if(!p_igetw(&combos_used,f))
550 {
551 goto error;
552 }
553 for (int32_t i=0; i<combos_used; i++)
554 {
555 if(!pfread(trashbuf,sizeof(newcombo),f))
556 {
557 goto error;
558 }
559 }
560
561 //read the palette info and make sure it worked
562 for (int32_t i=0; i<48; i++)
563 {
564 if(!pfread(trashbuf,newpdTOTAL,f))
565 {
566 goto error;
567 }
568 }
569 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
570 {
571 goto error;
572 }
573 for (int32_t i=0; i<MAXLEVELS; i++)
574 {
575 if(!pfread(trashbuf,PALNAMESIZE,f))
576 {
577 goto error;
578 }
579 }
580
581 //read the sprite info and make sure it worked
582 for (int32_t i=0; i<MAXITEMS; i++)
583 {
584 if(!pfread(trashbuf,sizeof(itemdata),f))
585 {
586 goto error;
587 }
588 }
589
590 for (int32_t i=0; i<MAXWPNS; i++)
591 {
592 if(!pfread(trashbuf,sizeof(wpndata),f))
593 {
594 goto error;
595 }
596 }
597
598 //read the triforce pieces info and make sure it worked
599 for (int32_t i=0; i<8; ++i)
600 {
601 if(!p_getc(&trashbuf,f))
602 {
603 goto error;
604 }
605 }
606
607
608
609 //read the game icons info and make sure it worked
610 for (int32_t i=0; i<4; ++i)
611 {
612 if(!p_igetw(&trashbuf,f))
613 {
614 goto error;
615 }
616 }
617
618 //read the misc colors info and map styles info and make sure it worked
619 if(!pfread(trashbuf,sizeof(zcolors),f))
620 {
621 goto error;
622 }
623
624 //read the template screens and make sure it worked
625 byte num_maps;
626 if(!p_getc(&num_maps,f))
627 {
628 goto error;
629 }
630 for (int32_t i=0; i<TEMPLATES; i++)
631 {
632 if(!pfread(trashbuf,sizeof(mapscr),f))
633 {
634 goto error;
635 }
636 }
637 if (num_maps>1) //dungeon templates
638 {
639 for (int32_t i=0; i<TEMPLATES; i++)
640 {
641 if(!pfread(trashbuf,sizeof(mapscr),f))
642 {
643 goto error;
644 }
645 }
646 }
647
648 //yay! it worked! close the file and say everything was ok.
649 pack_fclose(f);
650 return true;
651
652 error:
653 pack_fclose(f);
654 return false;*/
655 }
656
657 bool valid_zqt(const char *filename)
658 {
659 PACKFILE *f=NULL;
660 bool isvalid;
661 int32_t error;
662 f=open_quest_file(&error, filename, false);
663
664 if(!f)
665 {
666 // setPackfilePassword(NULL);
667 return false;
668 }
669
670 isvalid=valid_zqt(f);
671
672 clear_quest_tmpfile();
673 pack_fclose(f);
674
675 // setPackfilePassword(NULL);
676 return isvalid;
677 }
678
679 static std::string tmp_file_name;
680 258 void clear_quest_tmpfile()
681 {
682
1/2
✓ Branch 0 taken 258 times.
✗ Branch 1 not taken.
258 if(tmp_file_name.size())
683 {
684 if(exists(tmp_file_name.c_str()))
685 delete_file(tmp_file_name.c_str());
686 tmp_file_name.clear();
687 }
688 258 }
689 /*
690 .qst file history
691
692 .qst files have always been compressed using allegro's packfiles.
693
694 At some point, an encoding layer was added. The two layers look like this:
695
696 1) The top layer is from us. See decode_file_007.
697 [0-24] Preamble "Zelda Classic Quest File"
698 [25-28] Initial decoding seed value.
699 [29-X] Allegro-encoded payload (AKA "packed" file)
700 [last 4] Checksum
701
702 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
703 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
704 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
705 The oldest quests skip the password part.
706
707 Simply, the job of this function is to peel away the top layer.
708
709 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
710 in opening and saving files. There is no version field, so they decryption key is
711 found via trial-by-error (very slow!)
712
713 There are other file types of interest:
714 - .zqt: quest template files, skips top-layer encryption pass
715 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
716 - .qu?: same as above. automated backup files
717 - .qb?: same as above. automated backup files
718 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
719
720 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
721 files are now "slh!.AG ZC Enhanced Quest File".
722 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
723 */
724 129 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
725 {
726
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (show_progress)
727 {
728 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
729 }
730
731 #ifdef __EMSCRIPTEN__
732 if (em_is_lazy_file(filename))
733 {
734 em_fetch_file(filename);
735 }
736 #endif
737 129 clear_quest_tmpfile();
738 // Note: although this is primarily for loading .qst files, it can also handle all of the
739 // file types mentioned in the comment above. No need to be told if the file being loaded
740 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
741 129 bool top_layer_compressed = false;
742 129 bool compressed = false;
743 129 bool encrypted = false;
744
745 // Input files may or may not include a top layer, which may or may not be compressed.
746 // Additionally, the bottom layer may or may not be compressed, and may or may not be encoded
747 // with an allegro packfile password (longtan).
748 // We peek into this file to read the header - we'll either see the top layer's header (ENC_STR)
749 // or the bottom layer's header (QH_IDSTR or QH_NEWIDSTR).
750 // Newly saved .qst files enjoy a fast path here, where there is no top layer at all.
751
752 129 bool id_came_from_compressed_file = false;
753 129 const char* packfile_password = "";
754 char id[32];
755 129 id[0] = id[31] = '\0';
756 129 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, "");
757
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 3 times.
129 if (!pf)
758 3 pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password = datapwd);
759
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 3 times.
129 if (pf)
760 {
761 126 id_came_from_compressed_file = true;
762
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (!pack_fread(id, sizeof(id)-1, pf))
763 {
764 pack_fclose(pf);
765 Z_message("Unable to read header string\n");
766 return nullptr;
767 }
768 126 pack_fclose(pf);
769 126 }
770 else
771 {
772 3 FILE* f = fopen(filename, "rb");
773
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!f)
774 {
775 *open_error=qe_notfound;
776 return nullptr;
777 }
778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!fread(id, sizeof(char), sizeof(id)-1, f))
779 {
780 fclose(f);
781 Z_message("Unable to read header string\n");
782 return nullptr;
783 }
784 3 fclose(f);
785 }
786
787
4/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3 times.
129 if (strstr(id, QH_NEWIDSTR) || strstr(id, QH_IDSTR))
788 {
789 // The given file is already just the bottom layer - nothing more to do.
790 // There's no way to rewind a packfile, so just open it again.
791
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (id_came_from_compressed_file)
792 {
793 126 return pack_fopen_password(filename, F_READ_PACKED, packfile_password);
794 }
795 else
796 {
797 return pack_fopen_password(filename, F_READ, "");
798 }
799 }
800
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (strstr(id, ENC_STR))
801 {
802 3 top_layer_compressed = id_came_from_compressed_file;
803 3 compressed = true;
804 3 encrypted = true;
805 3 }
806 else if (id_came_from_compressed_file && strstr(id, "slh!\xff"))
807 {
808 // We must be reading the compressed contents of an allegro dataobject file. ex: `classic_qst.dat#NESQST_NEW_QST`.
809 // Let's extract the content and re-open as a separate file, so allegro will uncompress correctly.
810
811 char tmpfilename[L_tmpnam];
812 std::tmpnam(tmpfilename);
813 FILE* tf = fopen(tmpfilename, "wb");
814 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password);
815
816 int c;
817 while ((c = pack_getc(pf)) != EOF)
818 {
819 fputc(c, tf);
820 }
821 fclose(tf);
822 pack_fclose(pf);
823
824 tmp_file_name = tmpfilename; //store so it can be cleaned up later
825
826 // not good: temp file storage leak. Callers don't know to delete temp files anymore.
827 // We should put qsu in the dat file, or use a separate .qst file for new qst.
828 return pack_fopen_password(tmpfilename, F_READ_PACKED, "");
829 }
830 else
831 {
832 // Unexpected, this is going to fail some header check later.
833 }
834
835 // Everything below here is legacy code - recently saved quest files will have
836 // returned by now.
837
838 char tmpfilename[L_tmpnam];
839 3 temp_name(tmpfilename);
840 char percent_done[30];
841 3 int32_t current_method=0;
842
843 PACKFILE *f;
844 3 const char *passwd= encrypted ? datapwd : "";
845
846 // oldquest flag is set when an unencrypted qst file is suspected.
847 3 bool oldquest = false;
848 int32_t ret;
849
850
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
851 {
852 3 box_out(filename);
853 3 }
854 else
855 {
856 box_out("new quest"); // Or whatever
857 }
858 3 box_out("...");
859 3 box_eol();
860 3 box_eol();
861
862
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
863 {
864 3 box_out("Decrypting...");
865 3 box_save_x();
866 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
867
868
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
869 {
870 switch(ret)
871 {
872 case 1:
873 box_out("error.");
874 box_eol();
875 box_end(true);
876 *open_error=qe_notfound;
877 return NULL;
878
879 case 2:
880 box_out("error.");
881 box_eol();
882 box_end(true);
883 *open_error=qe_internal;
884 return NULL;
885 // be sure not to delete tmpfilename now...
886 }
887
888 if(ret==5) //old encryption?
889 {
890 current_method++;
891 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
892 box_out(percent_done);
893 box_load_x();
894 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
895 }
896
897 if(ret==5) //old encryption?
898 {
899 current_method++;
900 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
901 box_out(percent_done);
902 box_load_x();
903 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
904 }
905
906 if(ret==5) //old encryption?
907 {
908 current_method++;
909 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
910 box_out(percent_done);
911 box_load_x();
912 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
913 }
914
915 if(ret==5) //old encryption?
916 {
917 current_method++;
918 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
919 box_out(percent_done);
920 box_load_x();
921 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
922 }
923
924 if(ret)
925 {
926 oldquest = true;
927 passwd="";
928 }
929 }
930
931 3 box_out("okay.");
932 3 box_eol();
933 3 }
934 else
935 {
936 oldquest = true;
937 }
938
939 3 box_out("Opening...");
940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
941
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
942 {
943 if((compressed==1)&&(errno==EDOM))
944 {
945 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
946 }
947
948 if(!f)
949 {
950 if(!oldquest)
951 {
952 delete_file(tmpfilename);
953 }
954 box_out("error.");
955 box_eol();
956 box_end(true);
957 *open_error=qe_invalid;
958 return NULL;
959 }
960 }
961
962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
963 {
964 3 delete_file(tmpfilename);
965 3 }
966
967 3 box_out("okay.");
968 3 box_eol();
969
970 3 return f;
971 129 }
972
973 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
974 {
975 char *filename;
976 PACKFILE *f=NULL;
977 int32_t open_error=0;
978
979 strcpy(qstdat_string, "modules/classic/default.qst");
980 if(Header->templatepath[0]==0)
981 {
982 filename=(char *)malloc(2048);
983 strcpy(filename, qstdat_string);
984 }
985 else
986 {
987 // TODO: should be safe to remove this, no one seems to use custom quest templates.
988 filename=Header->templatepath;
989 }
990
991 f=open_quest_file(&open_error, filename, false);
992
993 if(Header->templatepath[0]==0)
994 {
995 free(filename);
996 }
997
998 if(!f)
999 {
1000 return NULL;
1001 }
1002
1003 if(validate)
1004 {
1005 if(!valid_zqt(f))
1006 {
1007 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1008 pack_fclose(f);
1009 clear_quest_tmpfile();
1010 return NULL;
1011 }
1012 }
1013
1014 return f;
1015 }
1016
1017 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
1018 {
1019 // We absolutely do not support loading from a template file to initialize data outside the editor.
1020 // TODO: move this code into zq/
1021 if (get_app_id() != App::zquest) return false;
1022
1023 combosread=false;
1024 mapsread=false;
1025 fixffcs=false;
1026
1027 switch(section_id)
1028 {
1029 case ID_RULES:
1030 case ID_STRINGS:
1031 case ID_MISC:
1032 case ID_TILES:
1033 case ID_COMBOS:
1034 case ID_CSETS:
1035 case ID_MAPS:
1036 case ID_DMAPS:
1037 case ID_DOORS:
1038 case ID_ITEMS:
1039 case ID_WEAPONS:
1040 case ID_COLORS:
1041 case ID_ICONS:
1042 case ID_INITDATA:
1043 case ID_GUYS:
1044 case ID_MIDIS:
1045 case ID_CHEATS:
1046 case ID_ITEMDROPSETS:
1047 case ID_FAVORITES:
1048 break;
1049
1050 default:
1051 return false;
1052 break;
1053 }
1054
1055 int32_t ret;
1056 word version, build;
1057 PACKFILE *f=NULL;
1058
1059 char deletefilename[1024];
1060 deletefilename[0]=0;
1061
1062 //why is this here?
1063 /*
1064 if(colordata==NULL)
1065 return false;
1066 */
1067
1068 //setPackfilePassword(datapwd);
1069 f=open_quest_template(Header, deletefilename, validate);
1070
1071 if(!f) //no file, nothing to delete
1072 {
1073 // setPackfilePassword(NULL);
1074 return false;
1075 }
1076
1077 ret=get_version_and_build(f, &version, &build);
1078
1079 if(ret||(version==0))
1080 {
1081 pack_fclose(f);
1082 clear_quest_tmpfile();
1083
1084 if(deletefilename[0])
1085 {
1086 delete_file(deletefilename);
1087 }
1088
1089 // setPackfilePassword(NULL);
1090 return false;
1091 }
1092
1093 if(!find_section(f, section_id))
1094 {
1095 al_trace("Can't find section!\n");
1096 pack_fclose(f);
1097 clear_quest_tmpfile();
1098
1099 if(deletefilename[0])
1100 {
1101 delete_file(deletefilename);
1102 }
1103
1104 //setPackfilePassword(NULL);
1105 return false;
1106 }
1107
1108 switch(section_id)
1109 {
1110 case ID_RULES:
1111 //rules
1112 ret=readrules(f, Header);
1113 break;
1114
1115 case ID_STRINGS:
1116 //strings
1117 ret=readstrings(f, Header);
1118 break;
1119
1120 case ID_MISC:
1121 //misc data
1122 ret=readmisc(f, Header, Misc);
1123 break;
1124
1125 case ID_TILES:
1126 //tiles
1127 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1128 break;
1129
1130 case ID_COMBOS:
1131 //combos
1132 clear_combos();
1133 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1134 combosread=true;
1135 break;
1136
1137 case ID_COMBOALIASES:
1138 //combos
1139 ret=readcomboaliases(f, Header, version, build);
1140 break;
1141
1142 case ID_CSETS:
1143 //color data
1144 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1145 break;
1146
1147 case ID_MAPS:
1148 //maps
1149 ret=readmaps(f, Header);
1150 mapsread=true;
1151 break;
1152
1153 case ID_DMAPS:
1154 //dmaps
1155 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1156 break;
1157
1158 case ID_DOORS:
1159 //door combo sets
1160 ret=readdoorcombosets(f, Header);
1161 break;
1162
1163 case ID_ITEMS:
1164 //items
1165 ret=readitems(f, version, build);
1166 break;
1167
1168 case ID_WEAPONS:
1169 //weapons
1170 ret=readweapons(f, Header);
1171 break;
1172
1173 case ID_COLORS:
1174 //misc. colors
1175 ret=readmisccolors(f, Header, Misc);
1176 break;
1177
1178 case ID_ICONS:
1179 //game icons
1180 ret=readgameicons(f, Header, Misc);
1181 break;
1182
1183 case ID_INITDATA:
1184 //initialization data
1185 ret=readinitdata(f, Header);
1186 break;
1187
1188 case ID_GUYS:
1189 //guys
1190 ret=readguys(f, Header);
1191 break;
1192
1193 case ID_MIDIS:
1194 //midis
1195 ret=readtunes(f, Header, tunes);
1196 break;
1197
1198 case ID_CHEATS:
1199 //cheat codes
1200 ret=readcheatcodes(f, Header);
1201 break;
1202
1203 case ID_ITEMDROPSETS:
1204 //item drop sets
1205 // Why is this one commented out?
1206 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1207 break;
1208
1209 case ID_FAVORITES:
1210 // favorite combos and aliases
1211 ret=readfavorites(f, version, build);
1212 break;
1213
1214 default:
1215 ret=-1;
1216 break;
1217 }
1218
1219 pack_fclose(f);
1220 clear_quest_tmpfile();
1221
1222 if(deletefilename[0])
1223 {
1224 delete_file(deletefilename);
1225 }
1226
1227 //setPackfilePassword(NULL);
1228 if(!ret)
1229 {
1230 return true;
1231 }
1232
1233 return false;
1234 }
1235
1236 bool init_tiles(bool validate, zquestheader *Header)
1237 {
1238 return init_section(Header, ID_TILES, NULL, NULL, validate);
1239 }
1240
1241 bool init_combos(bool validate, zquestheader *Header)
1242 {
1243 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1244 }
1245
1246 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1247 {
1248 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1249 }
1250
1251 129 void init_spritelists()
1252 {
1253
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if(FFCore.quest_format[vZelda] < 0x255)
1254 {
1255 93 guys.setMax(255);
1256 93 items.setMax(255);
1257 93 Ewpns.setMax(255);
1258 93 Lwpns.setMax(255);
1259 93 chainlinks.setMax(255);
1260 93 decorations.setMax(255);
1261 93 particles.setMax(255);
1262 93 }
1263 else
1264 {
1265 36 guys.setMax(255);
1266 36 items.setMax(255);
1267 36 Ewpns.setMax(255);
1268 36 Lwpns.setMax(255);
1269 36 chainlinks.setMax(255);
1270 36 decorations.setMax(255);
1271 36 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1272 }
1273 129 }
1274
1275 115 bool reset_items(bool validate, zquestheader *Header)
1276 {
1277 115 bool ret = true;
1278
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if (get_app_id() == App::zquest)
1279 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1280
1281
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 29440 times.
29555 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1282
1283 115 return ret;
1284 }
1285
1286 bool reset_guys()
1287 {
1288 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1289 init_guys(V_GUYS);
1290 return true;
1291 }
1292
1293 bool reset_wpns(bool validate, zquestheader *Header)
1294 {
1295 bool ret = true;
1296 if (get_app_id() == App::zquest)
1297 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1298
1299 for(int32_t i=0; i<MAXWPNS; i++)
1300 reset_weaponname(i);
1301
1302 return ret;
1303 }
1304
1305 bool reset_mapstyles(bool validate, miscQdata *Misc)
1306 {
1307 Misc->colors.blueframe_tile = 20044;
1308 Misc->colors.blueframe_cset = 0;
1309 Misc->colors.triforce_tile = 23461;
1310 Misc->colors.triforce_cset = 1;
1311 Misc->colors.triframe_tile = 18752;
1312 Misc->colors.triframe_cset = 1;
1313 Misc->colors.overworld_map_tile = 16990;
1314 Misc->colors.overworld_map_cset = 2;
1315 Misc->colors.HCpieces_tile = 21160;
1316 Misc->colors.HCpieces_cset = 8;
1317 Misc->colors.dungeon_map_tile = 19651;
1318 Misc->colors.dungeon_map_cset = 8;
1319 return true;
1320 }
1321
1322 115 int32_t get_qst_buffers()
1323 {
1324 115 memrequested+=(sizeof(mapscr)*MAPSCRS);
1325 115 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1326 115 TheMaps.resize(MAPSCRS);
1327 115 map_autolayers.resize(6);
1328
1329
2/2
✓ Branch 0 taken 15640 times.
✓ Branch 1 taken 115 times.
15755 for(int32_t i(0); i<MAPSCRS; i++)
1330 15640 TheMaps[i].zero_memory();
1331
1332 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1333 115 Z_message("OK\n"); // Allocating map buffer...
1334
1335 115 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1336 115 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1337
1338
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1339 return 0;
1340
1341 115 Z_message("OK\n");
1342
1343 // Allocating space for all 65535 strings uses up 10.62MB...
1344 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1345 // (Shoelace's "Hero of Dreams" uses 1415.)
1346 // So let's be a bit generous and allow 4096 initially.
1347 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1348 // I tested it and it worked without flaw on 6/6/11. - L.
1349 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1350 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1351 // See https://discord.com/channels/876899628556091432/992984989073416242
1352 115 msg_strings_size = 8192;
1353 115 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1354 115 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1355
1356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 MsgStrings = new MsgStr[msg_strings_size];
1357
1358 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1359
2/2
✓ Branch 0 taken 942080 times.
✓ Branch 1 taken 115 times.
942195 for(auto q = 0; q < msg_strings_size; ++q)
1360 {
1361 942080 MsgStrings[q].clear();
1362 942080 }
1363 115 Z_message("OK\n"); // Allocating string buffer...
1364
1365 115 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1366 115 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1367
1368
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1369 return 0;
1370
1371 115 Z_message("OK\n"); // Allocating door combo buffer...
1372
1373 115 memrequested+=(sizeof(dmap)*MAXDMAPS);
1374 115 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1375
1376
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1377 return 0;
1378
1379 115 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1380 115 Z_message("OK\n"); // Allocating dmap buffer...
1381
1382 115 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1383 115 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1384
1385 115 combobuf.clear();
1386 115 combobuf.resize(MAXCOMBOS);
1387 115 Z_message("OK\n"); // Allocating combo buffer...
1388
1389 115 memrequested+=(psTOTAL255);
1390 115 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1391
1392
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1393 return 0;
1394
1395 115 Z_message("OK\n"); // Allocating color data buffer...
1396
1397 115 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1398 115 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1399
1400 115 free_newtilebuf();
1401
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1402 return 0;
1403
1404 115 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1405 //Z_message("Performed memset on tiles\n");
1406 115 clear_tiles(newtilebuf);
1407 //Z_message("Performed clear_tiles()\n");
1408 115 Z_message("OK\n"); // Allocating tile buffer...
1409
1410
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(is_zquest())
1411 {
1412 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1413 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1414
1415 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1416 return 0;
1417
1418 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1419 clear_tiles(grabtilebuf);
1420 Z_message("OK\n"); // Allocating tile grab buffer...
1421 }
1422
1423 115 memrequested+=(100000);
1424 115 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1425
1426
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((trashbuf=(byte*)malloc(100000))==NULL)
1427 return 0;
1428
1429 115 Z_message("OK\n"); // Allocating trash buffer...
1430
1431 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1432 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1433 // fixed by ensuring there's actually itemdata there.
1434 // If you change this, be sure to update del_qst_buffers, too.
1435
1436 115 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1437 115 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1438
1439
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1440 return 0;
1441
1442 115 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1443 115 itemsbuf++;
1444 115 Z_message("OK\n"); // Allocating item buffer...
1445
1446 115 memrequested+=(sizeof(wpndata)*MAXWPNS);
1447 115 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1448
1449
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1450 return 0;
1451
1452 115 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1453 115 Z_message("OK\n"); // Allocating weapon buffer...
1454
1455 115 memrequested+=(sizeof(guydata)*MAXGUYS);
1456 115 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1457
1458
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1459 return 0;
1460
1461 115 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1462 115 Z_message("OK\n"); // Allocating guy buffer...
1463
1464 115 memrequested+=(sizeof(comboclass)*cMAX);
1465 115 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1466
1467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1468 return 0;
1469
1470 115 Z_message("OK\n"); // Allocating combo class buffer...
1471
1472 115 return 1;
1473 115 }
1474
1475
1476 115 void free_newtilebuf()
1477 {
1478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(newtilebuf)
1479 {
1480 for(int32_t i=0; i<NEWMAXTILES; i++)
1481 if(newtilebuf[i].data)
1482 free(newtilebuf[i].data);
1483
1484 free(newtilebuf);
1485 newtilebuf = 0;
1486 }
1487 115 }
1488
1489 void free_grabtilebuf()
1490 {
1491 if(is_zquest())
1492 {
1493 if(grabtilebuf)
1494 {
1495 for(int32_t i=0; i<NEWMAXTILES; i++)
1496 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1497
1498 free(grabtilebuf);
1499 grabtilebuf = 0;
1500 }
1501 }
1502 }
1503
1504 void del_qst_buffers()
1505 {
1506 al_trace("Cleaning maps. \n");
1507
1508 if(ZCMaps) free(ZCMaps);
1509
1510 if(MsgStrings) delete[] MsgStrings;
1511
1512 if(DoorComboSets) free(DoorComboSets);
1513
1514 if(DMaps) free(DMaps);
1515
1516 combobuf.clear();
1517
1518 if(colordata) free(colordata);
1519
1520 al_trace("Cleaning tile buffers. \n");
1521 free_newtilebuf();
1522 free_grabtilebuf();
1523
1524 al_trace("Cleaning misc. \n");
1525
1526 if(trashbuf) free(trashbuf);
1527
1528 // See get_qst_buffers
1529 if(itemsbuf)
1530 {
1531 itemsbuf--;
1532 free(itemsbuf);
1533 }
1534
1535 if(wpnsbuf) free(wpnsbuf);
1536
1537 if(guysbuf) free(guysbuf);
1538
1539 if(combo_class_buf) free(combo_class_buf);
1540 }
1541
1542 4 bool init_palnames()
1543 {
1544 // if(palnames==NULL)
1545 // return false;
1546
1547
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1548 {
1549
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1550 {
1551 case 0:
1552 4 sprintf(palnames[x],"Overworld");
1553 4 break;
1554
1555 case 10:
1556 4 sprintf(palnames[x],"Caves");
1557 4 break;
1558
1559 case 11:
1560 4 sprintf(palnames[x],"Passageways");
1561 4 break;
1562
1563 default:
1564 2036 sprintf(palnames[x],"%c",0);
1565 2036 break;
1566 }
1567 2048 }
1568
1569 4 return true;
1570 }
1571
1572 25132 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1573 {
1574 void *p;
1575
1576
1/2
✓ Branch 0 taken 25132 times.
✗ Branch 1 not taken.
25132 p = _AL_MALLOC(MAX(size, alloc_size));
1577
1578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25132 times.
25132 if(!p)
1579 {
1580 return NULL;
1581 }
1582
1583
1/2
✓ Branch 0 taken 25132 times.
✗ Branch 1 not taken.
25132 if(!pfread(p,size,f))
1584 {
1585 _AL_FREE(p);
1586 return NULL;
1587 }
1588
1589
1/2
✓ Branch 0 taken 25132 times.
✗ Branch 1 not taken.
25132 if(pack_ferror(f))
1590 {
1591 _AL_FREE(p);
1592 return NULL;
1593 }
1594
1595 25132 return p;
1596 25132 }
1597
1598 /* read_midi:
1599 * Reads MIDI data from a datafile (this is not the same thing as the
1600 * standard midi file format).
1601 */
1602
1603 2294 static MIDI *read_midi(PACKFILE *f)
1604 {
1605 MIDI *m;
1606 int32_t c;
1607 2294 int16_t divisions=0;
1608 2294 int32_t len=0;
1609
1610 2294 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1611
1612
1/2
✓ Branch 0 taken 2294 times.
✗ Branch 1 not taken.
2294 if(!m)
1613 {
1614 return NULL;
1615 }
1616
1617
2/2
✓ Branch 0 taken 73408 times.
✓ Branch 1 taken 2294 times.
75702 for(c=0; c<MIDI_TRACKS; c++)
1618 {
1619 73408 m->track[c].len = 0;
1620 73408 m->track[c].data = NULL;
1621 73408 }
1622
1623 2294 p_mgetw(&divisions,f);
1624 2294 m->divisions=divisions;
1625
1626
2/2
✓ Branch 0 taken 73408 times.
✓ Branch 1 taken 2294 times.
75702 for(c=0; c<MIDI_TRACKS; c++)
1627 {
1628 73408 p_mgetl(&len,f);
1629 73408 m->track[c].len=len;
1630
1631
2/2
✓ Branch 0 taken 48276 times.
✓ Branch 1 taken 25132 times.
73408 if(m->track[c].len > 0)
1632 {
1633 25132 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1634
1635
1/2
✓ Branch 0 taken 25132 times.
✗ Branch 1 not taken.
25132 if(!m->track[c].data)
1636 {
1637 destroy_midi(m);
1638 return NULL;
1639 }
1640 25132 }
1641 73408 }
1642
1643 LOCK_DATA(m, sizeof(MIDI));
1644
1645
2/2
✓ Branch 0 taken 73408 times.
✓ Branch 1 taken 2294 times.
75702 for(c=0; c<MIDI_TRACKS; c++)
1646 {
1647
2/2
✓ Branch 0 taken 25132 times.
✓ Branch 1 taken 48276 times.
73408 if(m->track[c].data)
1648 {
1649 LOCK_DATA(m->track[c].data, m->track[c].len);
1650 25132 }
1651 73408 }
1652
1653 2294 return m;
1654 2294 }
1655
1656 void clear_combo(int32_t i)
1657 {
1658 combobuf[i].clear();
1659 }
1660
1661 void clear_combos()
1662 {
1663 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1664 clear_combo(tmpcounter);
1665 }
1666
1667 void pack_combos()
1668 {
1669 int32_t di = 0;
1670
1671 for(int32_t si=0; si<1024; si+=2)
1672 combobuf[di++] = combobuf[si];
1673
1674 for(; di<1024; di++)
1675 clear_combo(di);
1676 }
1677
1678 129 void reset_tunes(zctune *tune)
1679 {
1680
2/2
✓ Branch 0 taken 32508 times.
✓ Branch 1 taken 129 times.
32637 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1681 {
1682 32508 tune[i].reset();
1683 32508 }
1684 129 }
1685
1686
1687 /*void reset_midi(zcmidi_ *m)
1688 {
1689 m->title[0]=0;
1690 m->loop=1;
1691 m->volume=144;
1692 m->start=0;
1693 m->loop_start=-1;
1694 m->loop_end=-1;
1695 if(m->midi)
1696 {
1697 destroy_midi(m->midi);
1698 }
1699 m->midi=NULL;
1700 }
1701
1702
1703 void reset_midis(zcmidi_ *m)
1704 {
1705 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1706 {
1707 reset_midi(m+i);
1708 }
1709 }
1710 */
1711
1712 void reset_scr(int32_t scr)
1713 {
1714 /*
1715 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1716 for(unsigned i=0; i<sizeof(mapscr); i++)
1717 *(di++) = 0;
1718 TheMaps[scr].valid=mVERSION;
1719 */
1720
1721 TheMaps[scr].zero_memory();
1722 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1723
1724 for(int32_t i=0; i<6; i++)
1725 {
1726 //these will be uncommented later
1727 //TheMaps[scr].layerxsize[i]=16;
1728 //TheMaps[scr].layerysize[i]=11;
1729 TheMaps[scr].layeropacity[i]=255;
1730 }
1731
1732 TheMaps[scr].valid=mVERSION;
1733
1734 }
1735
1736 /* For reference:
1737
1738 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1739 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1740 */
1741
1742 3574 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1743 {
1744
2/2
✓ Branch 0 taken 16422 times.
✓ Branch 1 taken 1606 times.
18028 for(int32_t i=0; i<9; i++)
1745 {
1746
2/2
✓ Branch 0 taken 88692 times.
✓ Branch 1 taken 14454 times.
103146 for(int32_t j=0; j<6; j++)
1747 {
1748
2/2
✓ Branch 0 taken 28908 times.
✓ Branch 1 taken 59784 times.
88692 if(j<4)
1749 {
1750
2/2
✓ Branch 0 taken 57816 times.
✓ Branch 1 taken 1968 times.
59784 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1751 {
1752 1968 return false;
1753 }
1754
1755
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1756 {
1757 return false;
1758 }
1759
1760
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1761 {
1762 return false;
1763 }
1764
1765
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1766 {
1767 return false;
1768 }
1769 57816 }
1770
1771
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1772 {
1773 return false;
1774 }
1775
1776
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1777 {
1778 return false;
1779 }
1780
1781
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1782 {
1783 return false;
1784 }
1785
1786
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1787 {
1788 return false;
1789 }
1790 86724 }
1791
1792
2/2
✓ Branch 0 taken 11242 times.
✓ Branch 1 taken 3212 times.
14454 if(i<2)
1793 {
1794
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.flags[i]!=b.flags[i])
1795 {
1796 return false;
1797 }
1798
1799
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1800 {
1801 return false;
1802 }
1803
1804
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1805 {
1806 return false;
1807 }
1808
1809
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1810 {
1811 return false;
1812 }
1813
1814
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1815 {
1816 return false;
1817 }
1818 3212 }
1819
1820
2/2
✓ Branch 0 taken 9636 times.
✓ Branch 1 taken 4818 times.
14454 if(i<3)
1821 {
1822
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1823 {
1824 return false;
1825 }
1826
1827
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1828 {
1829 return false;
1830 }
1831
1832
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1833 {
1834 return false;
1835 }
1836
1837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4818 times.
4818 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1838 {
1839 return false;
1840 }
1841 4818 }
1842
1843
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1844 {
1845 return false;
1846 }
1847
1848
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1849 {
1850 return false;
1851 }
1852 14454 }
1853
1854 1606 return true;
1855 3574 }
1856
1857 int32_t doortranslations_u[9][4]=
1858 {
1859 {37,38,53,54},
1860 {37,38,39,40},
1861 {37,38,55,56},
1862 {37,38,39,40},
1863 {37,38,53,54},
1864 {37,38,53,54},
1865 {37,38,53,54},
1866 {7,8,23,24},
1867 {7,8,41,42}
1868 };
1869
1870 int32_t doortranslations_d[9][4]=
1871 {
1872 {117,118,133,134},
1873 {135,136,133,134},
1874 {119,120,133,134},
1875 {135,136,133,134},
1876 {117,118,133,134},
1877 {117,118,133,134},
1878 {117,118,133,134},
1879 {151,152,167,168},
1880 {137,138,167,168},
1881 };
1882
1883 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1884 int32_t doortranslations_l[9][6]=
1885 {
1886 {66,67,82,83,98,99},
1887 {66,68,82,84,98,100},
1888 {66,69,82,85,98,101},
1889 {66,68,82,84,98,100},
1890 {66,67,82,83,98,99},
1891 {66,67,82,83,98,99},
1892 {66,67,82,83,98,99},
1893 {64,65,80,81,96,97},
1894 {64,65,80,114,96,97},
1895 };
1896
1897 int32_t doortranslations_r[9][6]=
1898 {
1899
1900 {76,77,92,93,108,109},
1901 {75,77,91,93,107,109},
1902 {74,77,90,93,106,109},
1903 {75,77,91,93,107,109},
1904 {76,77,92,93,108,109},
1905 {76,77,92,93,108,109},
1906 {76,77,92,93,108,109},
1907 {78,79,94,95,110,111},
1908 {78,79,125,95,110,111},
1909 };
1910
1911 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1912 {
1913 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1914 }
1915
1916 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1917 {
1918 //these are here to bypass compiler warnings about unused arguments
1919 308180 map=map;
1920 308180 scr=scr;
1921 308180 pos=pos;
1922
1923 //what does this function do?
1924 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1925 308180 return 2;
1926 }
1927
1928 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1929 {
1930
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1931 {
1932 5450 return 0;
1933 }
1934
1935 DoorComboSet tempdcs;
1936 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1937
1938 //up
1939
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1940 {
1941
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1942 {
1943 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1944 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1945 58392 }
1946 14598 }
1947
1948 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1949 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1950 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1951 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1952 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1953 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1954
1955 //down
1956
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1957 {
1958
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1959 {
1960 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1961 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1962 58392 }
1963 14598 }
1964
1965 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1966
1967 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1968 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1969 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1970 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1971 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1972
1973 //left
1974 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1975
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1976 {
1977
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1978 {
1979 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1980 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1981 87588 }
1982 14598 }
1983
1984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1985 {
1986 if((j!=2)&&(j!=3))
1987 {
1988 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1989 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1990 }
1991 }
1992
1993 1622 tempdcs.bombdoorcombo_l[0]=0;
1994 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1995 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1996 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1997 1622 tempdcs.bombdoorcombo_l[2]=0;
1998 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1999 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
2000 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
2001
2002 //right
2003
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
2004 {
2005
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
2006 {
2007 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
2008 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
2009 87588 }
2010 14598 }
2011
2012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
2013 {
2014 if((j!=2)&&(j!=3))
2015 {
2016 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
2017 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
2018 }
2019 }
2020
2021 1622 tempdcs.bombdoorcombo_r[0]=0;
2022 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
2023 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
2024 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
2025 1622 tempdcs.bombdoorcombo_r[2]=0;
2026 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
2027 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
2028 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
2029
2030 int32_t k;
2031
2032
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 3574 times.
3590 for(k=0; k<door_combo_set_count; k++)
2033 {
2034
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 1968 times.
3574 if(DoorComboSets[k]==tempdcs)
2035 {
2036 1606 break;
2037 }
2038 1968 }
2039
2040
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 16 times.
1622 if(k==door_combo_set_count)
2041 {
2042 16 DoorComboSets[k]=tempdcs;
2043 16 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
2044 16 ++door_combo_set_count;
2045 16 }
2046
2047 1622 return k;
2048 /*
2049 doorcombo_u[9][4];
2050 doorcset_u[9][4];
2051 doorcombo_d[9][4];
2052 doorcset_d[9][4];
2053 doorcombo_l[9][6];
2054 doorcset_l[9][6];
2055 doorcombo_r[9][6];
2056 doorcset_r[9][6];
2057 bombdoorcombo_u[2];
2058 bombdoorcset_u[2];
2059 bombdoorcombo_d[2];
2060 bombdoorcset_d[2];
2061 bombdoorcombo_l[3];
2062 bombdoorcset_l[3];
2063 bombdoorcombo_r[3];
2064 bombdoorcset_r[3];
2065 walkthroughcombo[4];
2066 walkthroughcset[4];
2067 */
2068 7072 }
2069
2070 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
2071 {
2072 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
2073 }
2074
2075 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
2076 {
2077
2078 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
2079 }
2080
2081 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
2082 {
2083 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
2084 }
2085
2086
2087 16 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
2088 {
2089 char temp_pwd[30];
2090 16 memset(temp_pwd,0,30);
2091
2092
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(pwdkey!=0)
2093 {
2094 16 memcpy(temp_pwd,encrypted_pwd,30);
2095 16 temp_pwd[29]=0;
2096
2097
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 16 times.
496 for(int32_t i=0; i<30; i++)
2098 {
2099 480 temp_pwd[i] -= pwdkey;
2100 480 int32_t t=pwdkey>>15;
2101 480 pwdkey = (pwdkey<<1)+t;
2102 480 }
2103 16 }
2104
2105 16 memcpy(pwd,temp_pwd,30);
2106 16 }
2107
2108
2109 92 bool devpwd()
2110 {
2111 #ifdef _DEBUG
2112 return true;
2113 #endif
2114 92 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2115 }
2116 bool check_questpwd(zquestheader *Header, char *pwd)
2117 {
2118 #if DEVLEVEL > 3
2119 return true;
2120 #endif
2121
2122 if (devpwd()) return true;
2123 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2124 cvs_MD5Context ctx;
2125 uint8_t md5sum[16];
2126
2127 cvs_MD5Init(&ctx);
2128 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2129 cvs_MD5Final(md5sum, &ctx);
2130
2131 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2132 }
2133
2134 121 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2135 {
2136 121 zprint2("\n");
2137 121 zprint2("[ZQUEST CREATOR METADATA]\n");
2138
1/2
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
121 if(qst_num < moduledata.max_quest_files)
2139 zprint2("Loading module quest %d\n", qst_num+1);
2140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 if(path) zprint2("Loading '%s'\n", path);
2141
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 4 times.
121 if ( tempheader.new_version_id_main > 0 )
2142 {
2143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if(tempheader.new_version_id_fourth > 0)
2144 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2145 tempheader.new_version_id_main,tempheader.new_version_id_second,
2146 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2147 117 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2148 117 tempheader.new_version_id_main,tempheader.new_version_id_second,
2149 117 tempheader.new_version_id_third);
2150 117 }
2151 else
2152 {
2153
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2154 {
2155 case 0x255:
2156 {
2157 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2158 break;
2159 }
2160 case 0x254:
2161 {
2162 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2163 break;
2164 }
2165 case 0x250:
2166 {
2167 switch(tempheader.build)
2168 {
2169 case 19:
2170 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2171 case 20:
2172 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2173 case 21:
2174 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2175 case 22:
2176 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2177 case 23:
2178 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2179 case 24:
2180 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2181 case 25:
2182 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2183 case 26:
2184 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2185 case 27:
2186 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2187 case 28:
2188 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2189 case 29:
2190 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2191 case 30:
2192 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2193 case 31:
2194 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2195 case 32:
2196 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2197 case 33:
2198 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2199 default:
2200 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2201
2202 }
2203 break;
2204 }
2205
2206 case 0x211:
2207 {
2208 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2209 }
2210 case 0x210:
2211 {
2212 zprint2("Last saved in ZQuest Version: 2.10.x");
2213 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2214 break;
2215 }
2216 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2217 case 0x193:
2218 {
2219 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2220 }
2221 case 0x192:
2222 {
2223 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2224 }
2225 case 0x190:
2226 {
2227 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2228 }
2229 case 0x184:
2230 {
2231 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2232 }
2233 case 0x183:
2234 {
2235 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2236 }
2237 case 0x180:
2238 {
2239 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2240 }
2241 default:
2242 {
2243 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2244 }
2245 */
2246 }
2247 }
2248
3/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
121 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2249 28 zprint2("%s\n", tempheader.getAlphaVerStr());
2250 93 else zprint2("\n");
2251
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2252
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2253
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2254
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2255
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 117 times.
121 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2256
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2257 121 zprint2("\n");
2258 121 }
2259
2260 129 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2261 {
2262 int32_t dummy;
2263 zquestheader tempheader;
2264 char dummybuf[80];
2265 byte temp_map_count;
2266 byte temp_midi_flags[MIDIFLAGS_SIZE];
2267 word version;
2268 char temp_pwd[30], temp_pwd2[30];
2269 int16_t temp_pwdkey;
2270 cvs_MD5Context ctx;
2271 129 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2272 129 memset(&tempheader, 0, sizeof(tempheader));
2273 129 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2274
2275
2276
2277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2278 {
2279 Z_message("Unable to read header string\n");
2280 return qe_invalid;
2281 }
2282
2283 // check header
2284
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2285 {
2286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2287 {
2288 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2289 return qe_invalid;
2290 }
2291 4 }
2292
2293 129 int32_t templatepath_len=0;
2294
2295 129 tempheader.external_zinfo = false;
2296 129 read_zinfo = false;
2297
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2298 {
2299 byte padding;
2300
2301
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2302 {
2303 return qe_invalid;
2304 }
2305
2306
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f))
2307 {
2308 return qe_invalid;
2309 }
2310
2311 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2312
2313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2314 {
2315 return qe_version;
2316 }
2317
2318 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2319
2320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2321 {
2322 return qe_invalid;
2323 }
2324
2325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2326 {
2327 return qe_obsolete;
2328 }
2329
2330
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f))
2331 {
2332 return qe_invalid;
2333 }
2334
2335
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f))
2336 {
2337 return qe_invalid;
2338 }
2339
2340 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2341
2342
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f))
2343 {
2344 return qe_invalid;
2345 }
2346
2347
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f))
2348 {
2349 return qe_invalid;
2350 }
2351
2352 4 FFCore.quest_format[qMapCount] = temp_map_count;
2353
2354
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f))
2355 {
2356 return qe_invalid;
2357 }
2358
2359
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2360 {
2361 return qe_invalid;
2362 }
2363
2364
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f))
2365 {
2366 return qe_invalid;
2367 }
2368
2369
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2370 {
2371 return qe_invalid;
2372 }
2373
2374
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f))
2375 {
2376 return qe_invalid;
2377 }
2378
2379
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f))
2380 {
2381 return qe_invalid;
2382 }
2383
2384
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f))
2385 {
2386 return qe_invalid;
2387 }
2388
2389
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f))
2390 {
2391 return qe_invalid;
2392 }
2393
2394
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2395 {
2396 return qe_invalid;
2397 }
2398 // These fields are expected to end in null bytes!
2399 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2400
2401
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2402 {
2403 return qe_invalid;
2404 }
2405 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2406
2407
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2408 {
2409 return qe_invalid;
2410 }
2411
2412
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f))
2413 {
2414 return qe_invalid;
2415 }
2416
2417
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f))
2418 {
2419 return qe_invalid;
2420 }
2421
2422 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2423 4 cvs_MD5Init(&ctx);
2424 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2425 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2426
2427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2428 {
2429 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2430 // Not anymore...
2431 memset(tempheader.minver,0,17);
2432 tempheader.build=0;
2433 tempheader.use_keyfile=0;
2434 memset(tempheader.old_foo, 0, 9);
2435 }
2436 else
2437 {
2438
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f))
2439 {
2440 return qe_invalid;
2441 }
2442
2443
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f))
2444 {
2445 return qe_invalid;
2446 }
2447
2448 4 FFCore.quest_format[vBuild] = tempheader.build;
2449
2450
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f))
2451 {
2452 return qe_invalid;
2453 }
2454
2455
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f))
2456 {
2457 return qe_invalid;
2458 }
2459 } // starting at minver
2460
2461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2462 {
2463 memset(&quest_rules[4],0,16); // word rules3..rules10
2464 }
2465 else
2466 {
2467
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2468 {
2469 return qe_invalid; // starting at rules3
2470 }
2471
2472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2473 {
2474 4 set_qr(qr_MEANPLACEDTRAPS,0);
2475 4 }
2476 }
2477
2478
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2479 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2480 {
2481 4 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2482 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2483 4 set_qr(qr_BRKBLSHLDS_DEP,1);
2484 4 }
2485
2486
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2487 {
2488 byte *mf=temp_midi_flags;
2489
2490 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2491 {
2492 mf=(byte*)dummybuf;
2493 }
2494
2495 if(!pfread(mf,32,f)) // read new header additions
2496 {
2497 return qe_invalid; // starting at foo2
2498 }
2499
2500 if(!pfread(dummybuf,18,f)) // read new header additions
2501 {
2502 return qe_invalid; // starting at foo2
2503 }
2504 }
2505
2506
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2507 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2508 {
2509 4 memset(tempheader.templatepath,0,2048);
2510 4 }
2511 else
2512 {
2513 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2514 {
2515 return qe_invalid;
2516 }
2517 }
2518
2519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2520 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2521 {
2522 4 tempheader.use_keyfile=0;
2523 4 }
2524 4 }
2525 else
2526 {
2527 //section id
2528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(!p_mgetl(&dummy,f))
2529 {
2530 return qe_invalid;
2531 }
2532
2533 //section version info
2534
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&version,f))
2535 {
2536 return qe_invalid;
2537 }
2538
2539 125 FFCore.quest_format[vHeader] = version;
2540
2541
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
2542 {
2543 return qe_invalid;
2544 }
2545
2546 //section size
2547
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
2548 {
2549 return qe_invalid;
2550 }
2551
2552 //finally... section data
2553
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&tempheader.zelda_version,f))
2554 {
2555 return qe_invalid;
2556 }
2557
2558 125 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2559
2560 //do some quick checking...
2561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(tempheader.zelda_version > ZELDA_VERSION)
2562 {
2563 return qe_version;
2564 }
2565
2566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2567 {
2568 return qe_invalid;
2569 }
2570
2571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(bad_version(tempheader.zelda_version))
2572 {
2573 return qe_obsolete;
2574 }
2575
2576
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.build,f))
2577 {
2578 return qe_invalid;
2579 }
2580
2581 125 FFCore.quest_format[vBuild] = tempheader.build;
2582
2583
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(version<3)
2584 {
2585
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(temp_pwd,30,f))
2586 {
2587 return qe_invalid;
2588 }
2589
2590
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_pwdkey,f))
2591 {
2592 return qe_invalid;
2593 }
2594
2595 12 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2596 12 cvs_MD5Init(&ctx);
2597 12 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2598 12 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2599 12 }
2600 else
2601 {
2602
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2603 {
2604 return qe_invalid;
2605 }
2606 }
2607
2608
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&tempheader.internal,f))
2609 {
2610 return qe_invalid;
2611 }
2612
2613
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.quest_number,f))
2614 {
2615 return qe_invalid;
2616 }
2617
2618 125 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2619
2620 125 size_t versz = version < 8 ? 9 : 16;
2621
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.version,versz,f))
2622 {
2623 return qe_invalid;
2624 }
2625
2626 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2627 //needs to be copied as char[9] or stored as a s.str
2628
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.minver,versz,f))
2629 {
2630 return qe_invalid;
2631 }
2632
2633 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2634
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2635 {
2636 return qe_invalid;
2637 }
2638 125 tempheader.title[sizeof(tempheader.title)-1] = 0;
2639
2640
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2641 {
2642 return qe_invalid;
2643 }
2644 125 tempheader.author[sizeof(tempheader.author)-1] = 0;
2645
2646
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.use_keyfile,f))
2647 {
2648 return qe_invalid;
2649 }
2650
2651 /*
2652 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2653 {
2654 return qe_invalid;
2655 }
2656 */
2657
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2658 {
2659 return qe_invalid;
2660 }
2661
2662
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(&dummybuf,4,f))
2663 {
2664 return qe_invalid;
2665 }
2666
2667
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2668 {
2669 return qe_invalid;
2670 }
2671
2672
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(dummybuf,14,f))
2673 {
2674 return qe_invalid;
2675 }
2676
2677 125 templatepath_len=sizeof(tempheader.templatepath);
2678
2679
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(version==1)
2680 {
2681 12 templatepath_len=280;
2682 12 }
2683
2684
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.templatepath,templatepath_len,f))
2685 {
2686 return qe_invalid;
2687 }
2688
2689
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&temp_map_count,f))
2690 {
2691 return qe_invalid;
2692 }
2693
2694
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(version>=4)
2695 {
2696
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_main,f))
2697 {
2698 return qe_invalid;
2699 }
2700
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_second,f))
2701 {
2702 return qe_invalid;
2703 }
2704
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_third,f))
2705 {
2706 return qe_invalid;
2707 }
2708
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2709 {
2710 return qe_invalid;
2711 }
2712
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2713 {
2714 return qe_invalid;
2715 }
2716
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_beta,f))
2717 {
2718 return qe_invalid;
2719 }
2720
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2721 {
2722 return qe_invalid;
2723 }
2724
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_release,f))
2725 {
2726 return qe_invalid;
2727 }
2728
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2729 {
2730 return qe_invalid;
2731 }
2732
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_month,f))
2733 {
2734 return qe_invalid;
2735 }
2736
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_day,f))
2737 {
2738 return qe_invalid;
2739 }
2740
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2741 {
2742 return qe_invalid;
2743 }
2744
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2745 {
2746 return qe_invalid;
2747 }
2748
2749
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_devsig,256,f))
2750 {
2751 return qe_invalid;
2752 }
2753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2754 strcpy(tempheader.new_version_devsig, "EmilyV99");
2755
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_compilername,256,f))
2756 {
2757 return qe_invalid;
2758 }
2759
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_compilerversion,256,f))
2760 {
2761 return qe_invalid;
2762 }
2763
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.product_name,1024,f))
2764 {
2765 return qe_invalid;
2766 }
2767
2768
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.compilerid,f))
2769 {
2770 return qe_invalid;
2771 }
2772
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2773 {
2774 return qe_invalid;
2775 }
2776
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2777 {
2778 return qe_invalid;
2779 }
2780
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2781 {
2782 return qe_invalid;
2783 }
2784
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2785 {
2786 return qe_invalid;
2787 }
2788
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&tempheader.developerid,f))
2789 {
2790 return qe_invalid;
2791 }
2792
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.made_in_module_name,1024,f))
2793 {
2794 return qe_invalid;
2795 }
2796
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.build_datestamp,256,f))
2797 {
2798 return qe_invalid;
2799 }
2800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!pfread(tempheader.build_timestamp,256,f))
2801 {
2802 return qe_invalid;
2803 }
2804 36 }
2805 else // <4
2806 {
2807 89 tempheader.new_version_id_main = 0;
2808 89 tempheader.new_version_id_second = 0;
2809 89 tempheader.new_version_id_third = 0;
2810 89 tempheader.new_version_id_fourth = 0;
2811 89 tempheader.new_version_id_alpha = 0;
2812 89 tempheader.new_version_id_beta = 0;
2813 89 tempheader.new_version_id_gamma = 0;
2814 89 tempheader.new_version_id_release = 0;
2815 89 tempheader.new_version_id_date_year = 0;
2816 89 tempheader.new_version_id_date_month = 0;
2817 89 tempheader.new_version_id_date_day = 0;
2818 89 tempheader.new_version_id_date_hour = 0;
2819 89 tempheader.new_version_id_date_minute = 0;
2820
2821 89 memset(tempheader.new_version_devsig, 0, 256);
2822 89 memset(tempheader.new_version_compilername, 0, 256);
2823 89 memset(tempheader.new_version_compilerversion, 0, 256);
2824 89 memset(tempheader.product_name, 0, 1024);
2825 89 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2826
2827 89 tempheader.compilerid = 0;
2828 89 tempheader.compilerversionnumber_first = 0;
2829 89 tempheader.compilerversionnumber_second = 0;
2830 89 tempheader.compilerversionnumber_third = 0;
2831 89 tempheader.compilerversionnumber_fourth = 0;
2832 89 tempheader.developerid = 0;
2833
2834 89 memset(tempheader.made_in_module_name, 0, 1024);
2835 89 memset(tempheader.build_datestamp, 0, 256);
2836 89 memset(tempheader.build_timestamp, 0, 256);
2837 }
2838
2839
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( version >= 5 )
2840 {
2841
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.build_timezone,6,f))
2842 {
2843 return qe_invalid;
2844 }
2845 36 }
2846 else // < 5
2847 {
2848 89 memset(tempheader.build_timezone, 0, 6);
2849 }
2850
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if ( version >= 6 )
2851 {
2852 byte b;
2853
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&b,f))
2854 {
2855 return qe_invalid;
2856 }
2857 36 tempheader.external_zinfo = b?true:false;
2858 36 read_zinfo = true;
2859 36 }
2860
2861
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(version >= 7)
2862 {
2863
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2864 {
2865 return qe_invalid;
2866 }
2867 36 }
2868 else
2869 {
2870 89 tempheader.new_version_is_nightly = false;
2871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(tempheader.zelda_version < 0x255)
2872 {
2873
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
89 switch(tempheader.zelda_version)
2874 {
2875 case 0x254:
2876 tempheader.new_version_id_main = 2;
2877 tempheader.new_version_id_second = 54;
2878 break;
2879 case 0x250:
2880
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 10 times.
✓ Branch 15 taken 1 times.
77 switch(tempheader.build)
2881 {
2882 case 19:
2883 tempheader.new_version_id_main = 2;
2884 tempheader.new_version_id_second = 50;
2885 tempheader.new_version_id_gamma = 1;
2886 break;
2887 case 20:
2888 tempheader.new_version_id_main = 2;
2889 tempheader.new_version_id_second = 50;
2890 tempheader.new_version_id_gamma = 2;
2891 break;
2892 case 21:
2893 tempheader.new_version_id_main = 2;
2894 tempheader.new_version_id_second = 50;
2895 tempheader.new_version_id_gamma = 3;
2896 break;
2897 case 22:
2898 tempheader.new_version_id_main = 2;
2899 tempheader.new_version_id_second = 50;
2900 tempheader.new_version_id_gamma = 4;
2901 break;
2902 case 23:
2903 tempheader.new_version_id_main = 2;
2904 tempheader.new_version_id_second = 50;
2905 tempheader.new_version_id_gamma = 5;
2906 break;
2907 case 24:
2908 22 tempheader.new_version_id_main = 2;
2909 22 tempheader.new_version_id_second = 50;
2910 22 tempheader.new_version_id_release = -1;
2911 22 break;
2912 case 25:
2913 tempheader.new_version_id_main = 2;
2914 tempheader.new_version_id_second = 50;
2915 tempheader.new_version_id_third = 1;
2916 tempheader.new_version_id_gamma = 1;
2917 break;
2918 case 26:
2919 tempheader.new_version_id_main = 2;
2920 tempheader.new_version_id_second = 50;
2921 tempheader.new_version_id_third = 1;
2922 tempheader.new_version_id_gamma = 2;
2923 break;
2924 case 27:
2925 tempheader.new_version_id_main = 2;
2926 tempheader.new_version_id_second = 50;
2927 tempheader.new_version_id_third = 1;
2928 tempheader.new_version_id_gamma = 3;
2929 break;
2930 case 28:
2931 5 tempheader.new_version_id_main = 2;
2932 5 tempheader.new_version_id_second = 50;
2933 5 tempheader.new_version_id_third = 1;
2934 5 tempheader.new_version_id_release = -1;
2935 5 break;
2936 case 29:
2937 24 tempheader.new_version_id_main = 2;
2938 24 tempheader.new_version_id_second = 50;
2939 24 tempheader.new_version_id_third = 2;
2940 24 tempheader.new_version_id_release = -1;
2941 24 break;
2942 case 30:
2943 tempheader.new_version_id_main = 2;
2944 tempheader.new_version_id_second = 50;
2945 tempheader.new_version_id_third = 3;
2946 tempheader.new_version_id_gamma = 1;
2947 break;
2948 case 31:
2949 15 tempheader.new_version_id_main = 2;
2950 15 tempheader.new_version_id_second = 53;
2951 15 tempheader.new_version_id_gamma = -1;
2952 15 break;
2953 case 32:
2954 10 tempheader.new_version_id_main = 2;
2955 10 tempheader.new_version_id_second = 53;
2956 10 tempheader.new_version_id_release = -1;
2957 10 break;
2958 case 33:
2959 1 tempheader.new_version_id_main = 2;
2960 1 tempheader.new_version_id_second = 53;
2961 1 tempheader.new_version_id_third = 1;
2962 1 break;
2963 }
2964 77 break;
2965
2966 case 0x211:
2967 tempheader.new_version_id_main = 2;
2968 tempheader.new_version_id_second = 11;
2969 tempheader.new_version_id_beta = tempheader.build;
2970 break;
2971 case 0x210:
2972 12 tempheader.new_version_id_main = 2;
2973 12 tempheader.new_version_id_second = 10;
2974 12 tempheader.new_version_id_beta = tempheader.build;
2975 12 break;
2976 }
2977 89 }
2978 }
2979
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(printmetadata || __isZQuest)
2980 {
2981 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2982 }
2983 }
2984
2985 //{ Version Warning
2986 129 int32_t vercmp = tempheader.compareVer();
2987 129 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2988 129 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2989
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
165 if(vercmp > 0 || (!vercmp &&
2990
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 (astatecmp > 0 || (!astatecmp &&
2991 36 avercmp > 0))))
2992 {
2993 bool r = true;
2994 if(loadquest_report)
2995 {
2996 enter_sys_pal();
2997 AlertDialog("Quest saved in newer version",
2998 "This quest was last saved in a newer version of ZQuest."
2999 " Attempting to load this quest may not work correctly; to"
3000 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
3001 "\n\nWould you like to continue loading anyway? (Not recommended)",
3002 [&](bool ret,bool)
3003 {
3004 r = ret;
3005 }).show();
3006 exit_sys_pal();
3007 }
3008 if(!r)
3009 return qe_silenterr;
3010 }
3011
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 else if(tempheader.compareDate() > 0)
3012 {
3013 bool r = true;
3014 if(loadquest_report)
3015 {
3016 enter_sys_pal();
3017 AlertDialog("Quest saved in newer build",
3018 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
3019 " issues loading in this build."
3020 "\n{}"
3021 "\n\nWould you like to continue loading anyway?",
3022 tempheader.getVerCmpStr()),
3023 [&](bool ret,bool)
3024 {
3025 r = ret;
3026 }).show();
3027 exit_sys_pal();
3028 }
3029 if(!r)
3030 return qe_silenterr;
3031 }
3032 //}
3033
3034 129 read_ext_zinfo = tempheader.external_zinfo;
3035
3036 129 memcpy(Header, &tempheader, sizeof(tempheader));
3037 129 map_count=temp_map_count;
3038 129 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
3039
3040 129 return 0;
3041 129 }
3042
3043 129 int32_t readrules(PACKFILE *f, zquestheader *Header)
3044 {
3045 int32_t dummy;
3046 zquestheader tempheader;
3047 129 word s_version=0;
3048 129 dword compatrule_version=0;
3049
3050 129 memcpy(&tempheader, Header, sizeof(tempheader));
3051
3052
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(tempheader.zelda_version >= 0x193)
3053 {
3054 //section version info
3055
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
3056 {
3057 return qe_invalid;
3058 }
3059
3060 125 FFCore.quest_format[vRules] = s_version;
3061
3062
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
3063 {
3064 return qe_invalid;
3065 }
3066
3067
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version > 16)
3068 {
3069
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&compatrule_version,f))
3070 {
3071 return qe_invalid;
3072 }
3073 36 }
3074 125 FFCore.quest_format[vCompatRule] = compatrule_version;
3075
3076 //section size
3077
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
3078 {
3079 return qe_invalid;
3080 }
3081
3082
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if ( s_version < 15 )
3083 {
3084 //finally... section data
3085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
3086 {
3087 return qe_invalid;
3088 }
3089 89 }
3090 else
3091 {
3092
3093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
3094 {
3095 return qe_invalid;
3096 }
3097
3098 }
3099 125 }
3100
3101 //al_trace("Rules version %d\n", s_version);
3102 //{ bunch of compat stuff
3103 129 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3104
3105
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<2)
3106 {
3107 16 set_qr(14,0);
3108 16 set_qr(27,0);
3109 16 set_qr(28,0);
3110 16 set_qr(29,0);
3111 16 set_qr(30,0);
3112 16 set_qr(32,0);
3113 16 set_qr(36,0);
3114 16 set_qr(49,0);
3115 16 set_qr(50,0);
3116 16 set_qr(51,0);
3117 16 set_qr(68,0);
3118 16 set_qr(75,0);
3119 16 set_qr(76,0);
3120 16 set_qr(98,0);
3121 16 set_qr(110,0);
3122 16 set_qr(113,0);
3123 16 set_qr(116,0);
3124 16 set_qr(102,0);
3125 16 set_qr(132,0);
3126 16 }
3127
3128 //Now, do any updates...
3129
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3130 {
3131 16 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
3132 16 set_qr(qr_REPLACEOPENDOORS, 1);
3133 16 set_qr(qr_OLDLENSORDER, 1);
3134 16 set_qr(qr_NOFAIRYGUYFIRES, 1);
3135 16 set_qr(qr_TRIGGERSREPEAT, 1);
3136 16 }
3137
3138
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3139 {
3140 4 set_qr(qr_WALLFLIERS,1);
3141 4 }
3142
3143
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3144 {
3145 4 set_qr(qr_NOBOMBPALFLASH,1);
3146 4 }
3147
3148
5/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
129 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3149 {
3150 6 set_qr(qr_NOSCROLLCONTINUE,1);
3151 6 }
3152
3153
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version <= 0x210)
3154 {
3155 16 set_qr(qr_ARROWCLIP,1);
3156 16 }
3157
3158
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 12 times.
127 if(tempheader.zelda_version == 0x210)
3159 {
3160 12 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
3161 12 set_qr(qr_CMBCYCLELAYERS, 0);
3162 12 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
3163 12 }
3164
3165
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 16 times.
127 if(tempheader.zelda_version <= 0x210)
3166 {
3167 16 set_qr(qr_OLDSTYLEWARP,1);
3168 16 set_qr(qr_210_WARPRETURN,1);
3169 16 }
3170
3171 //might not be correct
3172
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 4 times.
127 if(tempheader.zelda_version < 0x210)
3173 {
3174 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3175 4 set_qr(qr_OLDTRIBBLES_DEP,1);
3176 4 set_qr(qr_OLDHOOKSHOTGRAB,1);
3177 4 }
3178
3179
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 16 times.
127 if(tempheader.zelda_version < 0x211)
3180 {
3181 16 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
3182 16 }
3183
3184
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
127 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3185 {
3186 set_qr(qr_192b163_WARP,1);
3187 }
3188
3189
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 12 times.
127 if(tempheader.zelda_version == 0x210)
3190 {
3191 12 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3192 12 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3193 12 set_qr(qr_DMGCOMBOPRI, 0);
3194 12 }
3195
3196
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
127 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3197 {
3198 16 set_qr(qr_OLDPICKUP,1);
3199 16 }
3200
3201
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3202 {
3203 16 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3204 16 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3205 16 }
3206
3207
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3208 {
3209 16 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3210 16 }
3211
3212
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 22 times.
127 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3213 {
3214 22 set_qr(qr_PEAHATCLOCKVULN, 1);
3215 22 }
3216
3217
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 75 times.
127 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3218 {
3219 16 set_qr(qr_OLD_DOORREPAIR, 1);
3220 16 }
3221
3222
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
127 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3223 {
3224 16 set_qr(qr_OLD_SECRETMONEY, 1);
3225 16 }
3226
3227
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3228 {
3229 38 set_qr(qr_OLD_POTION_OR_HC, 1);
3230 38 }
3231
3232
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3233 {
3234 38 set_qr(qr_OFFSCREENWEAPONS, 1);
3235 38 }
3236
3237 //Bombchu fix.
3238
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 77 times.
131 if(tempheader.zelda_version == 0x250)
3239 {
3240
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 22 times.
77 if ( tempheader.build == 24 ) //2.50.0
3241 {
3242 22 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3243 22 }
3244
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 5 times.
77 if ( tempheader.build == 28 ) //2.50.1
3245 {
3246 5 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3247 5 }
3248
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
77 if ( tempheader.build == 29 ) //2.50.2
3249 {
3250 24 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3251 24 }
3252
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if ( tempheader.build == 30 ) //2.50.3RC1
3253 {
3254 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3255 }
3256 77 }
3257
3258
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 52 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3259 {
3260 // qr_OFFSETEWPNCOLLISIONFIX
3261 // All 'official' quests need this disabled.
3262 // All 2.10 and lower quests need this enabled to preseve compatability.
3263 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3264
3265 //~Gleeok
3266 43 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3267
3268 // Broke in build 695
3269
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
43 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3270 27 set_qr(qr_BROKENSTATUES, 1);
3271 43 }
3272
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if (tempheader.zelda_version <= 0x190)
3273 {
3274 4 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3275 4 }
3276
9/10
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 36 times.
131 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3277 {
3278 94 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3279 94 }
3280
3281
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3282 {
3283 16 set_qr(qr_OLD_210_WATER, 1);
3284 16 }
3285
3286
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3287 {
3288 93 set_qr(qr_STEP_IS_FLOAT,0);
3289 93 }
3290
3291
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( tempheader.zelda_version < 0x250 )
3292 {
3293 16 set_qr(qr_8WAY_SHOT_SFX, 1);
3294 16 }
3295
3296
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 3)
3297 {
3298 16 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3299 16 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3300 16 }
3301
3302
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<4)
3303 {
3304 16 set_qr(10,0);
3305 16 }
3306
3307
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<5)
3308 {
3309 16 set_qr(27,0);
3310 16 }
3311
3312
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<6)
3313 {
3314 16 set_qr(46,0);
3315 16 }
3316
3317
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<7) // January 2008
3318 {
3319 16 set_qr(qr_HEARTSREQUIREDFIX,0);
3320 16 set_qr(qr_PUSHBLOCKCSETFIX,1);
3321 16 }
3322
3323
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version<8)
3324 {
3325 16 set_qr(12, 0);
3326 16 }
3327 else
3328 {
3329 113 set_bit(deprecated_rules, 12, 0);
3330 }
3331
3332
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<9) // October 2008
3333 {
3334 16 set_qr(qr_NOROPE2FLASH_DEP,0);
3335 16 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3336 16 set_qr(qr_GHINI2BLINK_DEP,0);
3337 16 set_qr(qr_PHANTOMGHINI2_DEP,0);
3338 16 }
3339
3340
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<10) // December 2008
3341 {
3342 16 set_qr(qr_NOCLOCKS_DEP,0);
3343 16 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3344 16 }
3345
3346
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<11) // April 2009
3347 {
3348 16 set_qr(qr_SLOWENEMYANIM_DEP,0);
3349 16 }
3350
3351 // This served no purpose.
3352 // if(s_version<12) // December 2009
3353 // {
3354 // set_qr(qr_BRKBLSHLDS_DEP,0);
3355 // set_qr(qr_OLDTRIBBLES_DEP,0);
3356 // }
3357
3358 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3359
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 13)
3360 {
3361 16 set_qr(qr_SHOPCHEAT, 1);
3362 16 }
3363
3364 // Not entirely sure this is the best place for this...
3365 //2.50.2 bitmap offset fix
3366 129 memset(extra_rules, 0, EXTRARULES_SIZE);
3367
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 50 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3368 {
3369 43 set_er(er_BITMAPOFFSET, 1);
3370 43 set_qr(qr_BITMAPOFFSETFIX, 1);
3371 43 }
3372 //required because quest templates also used this bit, although
3373 //it never did anything, before. -Z
3374
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 77 times.
129 if ( tempheader.zelda_version == 0x250 )
3375 {
3376
5/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 38 times.
77 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3377 {
3378 39 set_er(er_BITMAPOFFSET, 0);
3379 39 set_qr(qr_BITMAPOFFSETFIX, 0);
3380 39 }
3381 77 }
3382
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if ( tempheader.zelda_version == 0x254 )
3383 {
3384 set_er(er_BITMAPOFFSET, 0);
3385 set_qr(qr_BITMAPOFFSETFIX, 0);
3386 }
3387
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
129 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3388 {
3389 set_er(er_BITMAPOFFSET, 0);
3390 set_qr(qr_BITMAPOFFSETFIX, 0);
3391 }
3392 //optimise fast drawing for older versions.
3393
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3394 {
3395 93 set_qr(qr_OLDSPRITEDRAWS, 1);
3396 93 }
3397 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3398 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3399 //older quests can set the rule by hand. We need a new qst.dat again.
3400
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3401 {
3402 set_qr(qr_OLDEWPNPARENT, 1);
3403 }
3404
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3405 {
3406 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3407 }
3408
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3409 {
3410 set_qr(qr_OLDQUESTMISC, 1);
3411 }
3412
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x254 )
3413 {
3414 93 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3415 93 set_qr(qr_OLDEWPNPARENT, 0);
3416 93 set_qr(qr_OLDQUESTMISC, 0);
3417 93 }
3418
3419 //item scripts continue to run
3420
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3421 {
3422 93 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3423 93 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3424 93 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3425 93 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3426 93 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3427 93 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3428 93 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3429 93 }
3430
3431
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3432 {
3433 93 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3434 93 }
3435
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3436 {
3437 93 set_qr(qr_TRACESCRIPTIDS, 0);
3438 93 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3439 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3440 93 set_qr(qr_PARSER_250DIVISION,1);
3441 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3442 93 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3443 93 set_qr(qr_PARSER_FORCE_INLINE,0);
3444 93 set_qr(qr_PARSER_BINARY_32BIT,0);
3445
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 2 times.
93 if ( get_qr(qr_SELECTAWPN) )
3446 {
3447 2 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3448 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3449 //Now they **do**, unless you disable that behaviour.
3450 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3451 //now enable the disable L/R item swap on load.
3452 2 }
3453
3454 93 }
3455
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3456 {
3457 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3458 93 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3459 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3460 //animations ending earlier than they should.
3461 93 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3462 //Enemies would ignore solidity on the top half of combos
3463 93 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3464 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3465 93 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3466 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3467 93 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3468 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3469 93 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3470 93 }
3471
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x255 )
3472 {
3473 93 set_qr(qr_NOFFCWAITDRAW, 1);
3474 93 set_qr(qr_NOITEMWAITDRAW, 1);
3475 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3476 93 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3477 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3478 93 }
3479
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3480 {
3481 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3482 93 }
3483
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3484 {
3485 93 set_qr(qr_OLD_PRINTF_ARGS, 1);
3486 93 }
3487
3488
3489
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3490 {
3491 93 set_qr(qr_BROKEN_RING_POWER, 1);
3492 93 }
3493
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3494 {
3495 93 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3496 93 }
3497
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3498 {
3499 93 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3500 93 }
3501
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3502 {
3503 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3504
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(get_qr(qr_SET_XBUTTON_ITEMS))
3505 set_qr(qr_SET_YBUTTON_ITEMS,1);
3506 93 }
3507
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3508 {
3509 93 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3510 93 }
3511
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3512 {
3513 93 set_qr(qr_OLD_CHEST_COLLISION,1);
3514 93 }
3515
3516
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x254 )
3517 {
3518 93 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3519 93 }
3520 //Sideview spikes in 2.50.0
3521
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 55 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3522 {
3523 38 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3524 38 }
3525 //more 2.50 fixes -Z
3526
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 26 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3527 {
3528 67 set_qr(qr_MELEEMAGICCOST, 0);
3529 67 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3530 67 set_qr(qr_OLDMIRRORCOMBOS, 1);
3531 67 set_qr(qr_BROKENBOOKCOST, 1);
3532 67 set_qr(qr_BROKENCHARINTDRAWING, 1);
3533
3534 67 }
3535
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3536 {
3537 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3538 set_qr(qr_MELEEMAGICCOST, 1);
3539 }
3540
3541
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(tempheader.zelda_version < 0x193)
3542 {
3543 4 set_qr(qr_SHORTDGNWALK, 1);
3544 4 }
3545
3546
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(tempheader.zelda_version < 0x255)
3547 {
3548 93 set_qr(qr_OLDINFMAGIC, 1);
3549 93 }
3550
3551
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3552 {
3553 16 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3554 16 }
3555
3556
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3557 {
3558 93 set_qr(qr_OLD_F6,1);
3559 93 }
3560
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3561 {
3562 93 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3563 93 }
3564
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3565 {
3566 93 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3567 93 }
3568
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3569 {
3570 93 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3571 93 }
3572 //}
3573
3574
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3575 93 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3576
3577
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 2) //Old CSet2 Handling
3578 93 set_qr(qr_OLDCS2,1);
3579
3580
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3581 93 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3582
3583
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3584 93 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3585
3586
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 77 times.
129 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3587 77 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3588
3589
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3590 93 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3591
3592
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3593 93 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3594
3595
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3596 93 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3597
3598
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 9)
3599 {
3600 //Hardcoded BS Patras
3601 93 set_qr(qr_HARDCODED_BS_PATRA,1);
3602 //Hardcoded Patra Inner Eye offsets
3603 93 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3604 //Broken 'Big enemy' animation style
3605 93 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3606 //Broken Attribute 31/32
3607 93 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3608 93 }
3609
3610
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 10) //Shared candle use limits
3611 93 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3612
3613
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 11) //No cross-screen return points
3614 93 set_qr(qr_OLD_RESPAWN_POINTS,1);
3615
3616
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 12)
3617 {
3618 //Old fire trail duration
3619 93 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3620 //Old Intro String in Ganon Room Behavior
3621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3622 93 else set_qr(qr_GANONINTRO,1);
3623 93 }
3624
3625
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
129 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3626 set_qr(qr_ANONE_NOANIM,1);
3627
3628
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 14) //Old Bridge Combo Behavior
3629 93 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3630
3631
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 15) //Broken Z3 Animation
3632 93 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3633
3634
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3635 93 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3636
3637
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 17)
3638 {
3639 //Old Quake/DrawYOffset behavior
3640 //set_qr(qr_OLD_DRAWOFFSET,1);
3641 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3642 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3643 93 }
3644
3645
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 18)
3646 {
3647 //Broken DrawScreen Derivative Functions
3648 93 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3649 //Scrolling Cancels Charge
3650 93 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3651 93 }
3652
3653
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3654 93 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3655
3656
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 20)
3657 93 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3658
3659
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 21)
3660 {
3661 93 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3662 93 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3663 93 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3664 93 set_qr(qr_OLD_BUG_NET,1);
3665 93 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3666 93 }
3667
3668
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 22)
3669 93 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3670
3671
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 23)
3672 93 set_qr(qr_OLD_HALF_MAGIC,1);
3673
3674
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 24)
3675 {
3676 93 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3677 93 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3678 93 }
3679
3680
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 25)
3681 {
3682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3683 93 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3684 93 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3685 93 }
3686
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 26)
3687 {
3688 93 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3689 93 set_qr(qr_POLVIRE_NO_SHADOW,1);
3690 93 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3691 93 }
3692
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3693 {
3694
2/2
✓ Branch 0 taken 27993 times.
✓ Branch 1 taken 93 times.
28086 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3695 27993 set_qr(q,0);
3696
2/2
✓ Branch 0 taken 10416 times.
✓ Branch 1 taken 93 times.
10509 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3697 10416 set_qr(q,0);
3698 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3699 93 }
3700
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 28)
3701 95 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3702
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 29)
3703 95 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3704
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 30)
3705 {
3706 95 set_qr(qr_DECO_2_YOFFSET,1);
3707 95 set_qr(qr_SCREENSTATE_80s_BUG,1);
3708 95 }
3709
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 31)
3710 {
3711 95 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3712 95 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3713 95 }
3714
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 32)
3715 95 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3716
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 33)
3717 95 set_qr(qr_NO_LIFT_SPRITE,1);
3718
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 34)
3719 {
3720 95 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3721 95 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3722 95 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3723 95 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3724 95 }
3725
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 35)
3726 {
3727 95 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3728 95 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3729 95 }
3730
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 36)
3731 95 set_qr(qr_OLD_SHALLOW_SFX,1);
3732
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 97 times.
129 if(compatrule_version < 37)
3733 97 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3734
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 97 times.
129 if(compatrule_version < 38)
3735 97 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3736
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 97 times.
129 if(compatrule_version < 39)
3737 97 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3738
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 97 times.
129 if(compatrule_version < 40)
3739 97 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3740
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 41)
3741 98 set_qr(qr_BROKENHITBY,1);
3742
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 42)
3743 98 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3744
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 43)
3745 98 set_qr(qr_OLD_BOMB_HITBOXES,1);
3746
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 44)
3747 98 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3748
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 45)
3749 98 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3750
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 46)
3751 98 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3752
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 101 times.
129 if(compatrule_version < 47)
3753 {
3754 101 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3755 101 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3756 101 }
3757
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 101 times.
129 if(compatrule_version < 48)
3758 101 set_qr(qr_OLD_GUY_HANDLING,1);
3759
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 101 times.
129 if(compatrule_version < 49)
3760 101 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3761
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 101 times.
129 if(compatrule_version < 50)
3762 101 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3763
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 101 times.
129 if(compatrule_version < 51)
3764 101 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3765
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 101 times.
129 if (compatrule_version < 52)
3766 101 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3767
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 101 times.
129 if(compatrule_version < 53)
3768 {
3769 101 set_qr(qr_OLD_SUBSCR,1);
3770 101 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3771 101 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3772 101 }
3773
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 121 times.
129 if(compatrule_version < 54)
3774 121 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(compatrule_version < 55)
3776 129 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3777
3778 129 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3779
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if (s_version < 16)
3780 93 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3781
3782 129 memcpy(Header, &tempheader, sizeof(tempheader));
3783
3784 129 return 0;
3785 129 }
3786
3787 1083741 void init_msgstr(MsgStr *str)
3788 {
3789 1083741 str->s = "";
3790 1083741 str->s.shrink_to_fit();
3791 1083741 str->nextstring=0;
3792 1083741 str->tile=0;
3793 1083741 str->cset=0;
3794 1083741 str->trans=false;
3795 1083741 str->font=font_zfont;
3796 1083741 str->y=32;
3797 1083741 str->sfx=18;
3798 1083741 str->listpos=0;
3799 1083741 str->x=24;
3800 1083741 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3801 1083741 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3802 1083741 str->hspace=0;
3803 1083741 str->vspace=0;
3804 1083741 str->stringflags=0;
3805 1083741 str->margins[up] = 8;
3806 1083741 str->margins[down] = 0;
3807 1083741 str->margins[left] = 8;
3808 1083741 str->margins[right] = 0;
3809 1083741 str->portrait_tile = 0;
3810 1083741 str->portrait_cset = 0;
3811 1083741 str->portrait_x = 0;
3812 1083741 str->portrait_y = 0;
3813 1083741 str->portrait_tw = 1;
3814 1083741 str->portrait_th = 1;
3815 1083741 str->shadow_type = 0;
3816 1083741 str->shadow_color = 0;
3817 1083741 str->drawlayer = 6;
3818 1083741 }
3819
3820 129 void init_msgstrings(int32_t start, int32_t end)
3821 {
3822
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if(end <= start || end-start > msg_strings_size)
3823 return;
3824
3825
2/2
✓ Branch 0 taken 1056768 times.
✓ Branch 1 taken 129 times.
1056897 for(int32_t i=start; i<end; i++)
3826 {
3827 1056768 init_msgstr(&MsgStrings[i]);
3828 1056768 MsgStrings[i].listpos=i;
3829 1056768 }
3830
3831
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(start==0)
3832 {
3833 129 MsgStrings[0].s = "(None)";
3834 129 MsgStrings[0].listpos = 0;
3835 129 }
3836 129 }
3837
3838 129 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3839 {
3840 129 MsgStr tempMsgString;
3841
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 init_msgstr(&tempMsgString);
3842
3843 129 word temp_msg_count=0;
3844 word temp_expansion[16];
3845 129 memset(temp_expansion, 0, 16*sizeof(word));
3846 129 char buf[8193] = {0};
3847
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version < 0x193)
3848 {
3849 byte tempbyte;
3850 4 int32_t strings_to_read=0;
3851
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3852
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3853 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3854 {
3855 4 strings_to_read=128;
3856 4 temp_msg_count=Header->old_str_count;
3857
3858 // Some sort of string count corruption seems to be common in old quests
3859
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3860 {
3861 temp_msg_count=128;
3862 }
3863 4 }
3864 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3865 {
3866 strings_to_read=255;
3867 temp_msg_count=Header->old_str_count;
3868 }
3869 else
3870 {
3871 if(!p_igetw(&temp_msg_count,f))
3872 {
3873 return qe_invalid;
3874 }
3875
3876 strings_to_read=temp_msg_count;
3877
3878 if(temp_msg_count >= msg_strings_size)
3879 {
3880 Z_message("Reallocating string buffer...\n");
3881
3882 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3883 // return qe_nomem;
3884
3885 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3886 delete[] MsgStrings;
3887 MsgStrings = new MsgStr[MAXMSGS];
3888 msg_strings_size = MAXMSGS;
3889 for(auto q = 0; q < msg_strings_size; ++q)
3890 {
3891 MsgStrings[q].clear();
3892 }
3893 }
3894 }
3895
3896 //reset the message strings
3897
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3898
3899
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3900 {
3901
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3902 512 tempMsgString.listpos = x;
3903
3904
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f))
3905 {
3906 return qe_invalid;
3907 }
3908
3909 512 buf[74] = '\0';
3910
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3911
3912
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3913 {
3914 return qe_invalid;
3915 }
3916
3917
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3918 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3919 {
3920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3921
3922
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3923 {
3924 return qe_invalid;
3925 }
3926
3927
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3928 {
3929 return qe_invalid;
3930 }
3931 512 }
3932 else
3933 {
3934 if(!p_igetw(&tempMsgString.nextstring,f))
3935 {
3936 return qe_invalid;
3937 }
3938
3939 if(!pfread(temp_expansion,32,f))
3940 {
3941 return qe_invalid;
3942 }
3943 }
3944
3945
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3946 512 }
3947 4 }
3948 else
3949 {
3950 int32_t dummy_int;
3951 word s_version;
3952 word s_cversion;
3953
3954 //section version info
3955
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_version,f))
3956 {
3957 return qe_invalid;
3958 }
3959
3960 125 FFCore.quest_format[vStrings] = s_version;
3961
3962
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_cversion,f))
3963 {
3964 return qe_invalid;
3965 }
3966
3967 //al_trace("Strings version %d\n", s_version);
3968 //section size
3969
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy_int,f))
3970 {
3971 return qe_invalid;
3972 }
3973
3974 //finally... section data
3975
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&temp_msg_count,f))
3976 {
3977 return qe_invalid;
3978 }
3979
3980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(temp_msg_count >= msg_strings_size)
3981 {
3982 Z_message("Reallocating string buffer...\n");
3983
3984 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3985 // return qe_nomem;
3986 delete[] MsgStrings;
3987 MsgStrings = new MsgStr[MAXMSGS];
3988 msg_strings_size = MAXMSGS;
3989 for(auto q = 0; q < msg_strings_size; ++q)
3990 {
3991 MsgStrings[q].clear();
3992 }
3993 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3994 }
3995
3996 //reset the message strings
3997
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version < 7)
3998
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3999
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 init_msgstrings(0,msg_strings_size);
4000
4001 125 int32_t string_length=(s_version<2)?73:145;
4002
4003
2/2
✓ Branch 0 taken 26332 times.
✓ Branch 1 taken 125 times.
26457 for(int32_t i=0; i<temp_msg_count; i++)
4004 {
4005
1/2
✓ Branch 0 taken 26332 times.
✗ Branch 1 not taken.
26332 init_msgstr(&tempMsgString);
4006 26332 tempMsgString.listpos = i;
4007
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 26139 times.
26332 if(s_version > 8)
4008 {
4009
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&string_length,f))
4010 {
4011 return qe_invalid;
4012 }
4013 193 }
4014
4015
2/4
✓ Branch 0 taken 26332 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26332 times.
26332 if (string_length < 0 || string_length > 8193)
4016 {
4017 return qe_invalid;
4018 }
4019
4020
1/2
✓ Branch 0 taken 26332 times.
✗ Branch 1 not taken.
26332 if (string_length > 0)
4021 {
4022
2/4
✓ Branch 0 taken 26332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26332 times.
✗ Branch 3 not taken.
26332 if (!pfread(buf, string_length, f))
4023 {
4024 return qe_invalid;
4025 }
4026 26332 }
4027 else
4028 {
4029 buf[0] = 0;
4030 }
4031
4032
2/4
✓ Branch 0 taken 26332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26332 times.
✗ Branch 3 not taken.
26332 if(!p_igetw(&tempMsgString.nextstring,f))
4033 {
4034 return qe_invalid;
4035 }
4036
4037
2/2
✓ Branch 0 taken 19101 times.
✓ Branch 1 taken 7231 times.
26332 if(s_version<2)
4038 {
4039 19101 buf[72] = '\0';
4040
1/2
✓ Branch 0 taken 19101 times.
✗ Branch 1 not taken.
19101 tempMsgString.s = buf;
4041 19101 }
4042 else
4043 {
4044 // June 2008: A bug corrupted the last 4 chars of a string.
4045 // Discard these.
4046
1/2
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
7231 if(s_version<3)
4047 {
4048 for(int32_t j=140; j<144; j++)
4049 {
4050 buf[j] = '\0';
4051 }
4052 }
4053
1/2
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
7231 if(string_length > 8192) string_length = 8192;
4054 7231 buf[string_length]='\0'; //Force-terminate
4055
1/2
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
7231 tempMsgString.s = buf;
4056
4057
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 7038 times.
7231 if ( s_version >= 6 )
4058 {
4059
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&tempMsgString.tile,f))
4060 {
4061 return qe_invalid;
4062 }
4063 193 }
4064 else
4065 {
4066
2/4
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7038 times.
✗ Branch 3 not taken.
7038 if(!p_igetw(&tempMsgString.tile,f))
4067 {
4068 return qe_invalid;
4069 }
4070 }
4071
4072
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_getc(&tempMsgString.cset,f))
4073 {
4074 return qe_invalid;
4075 }
4076
4077 byte dummy_char;
4078
4079
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
4080 {
4081 return qe_invalid;
4082 }
4083
4084 7231 tempMsgString.trans=dummy_char!=0;
4085
4086
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_getc(&tempMsgString.font,f))
4087 {
4088 return qe_invalid;
4089 }
4090
4091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7231 times.
7231 if(s_version < 5)
4092 {
4093 if(!p_getc(&tempMsgString.y,f))
4094 {
4095 return qe_invalid;
4096 }
4097 }
4098 else
4099 {
4100
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_igetw(&tempMsgString.x,f))
4101 {
4102 return qe_invalid;
4103 }
4104
4105
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_igetw(&tempMsgString.y,f))
4106 {
4107 return qe_invalid;
4108 }
4109
4110
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_igetw(&tempMsgString.w,f))
4111 {
4112 return qe_invalid;
4113 }
4114
4115
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_igetw(&tempMsgString.h,f))
4116 {
4117 return qe_invalid;
4118 }
4119
4120
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_getc(&tempMsgString.hspace,f))
4121 {
4122 return qe_invalid;
4123 }
4124
4125
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_getc(&tempMsgString.vspace,f))
4126 {
4127 return qe_invalid;
4128 }
4129
4130
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_getc(&tempMsgString.stringflags,f))
4131 {
4132 return qe_invalid;
4133 }
4134 }
4135
4136
2/2
✓ Branch 0 taken 7038 times.
✓ Branch 1 taken 193 times.
7231 if(s_version >= 7)
4137 {
4138
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 772 times.
965 for(int32_t q = 0; q < 4; ++q)
4139 {
4140
2/4
✓ Branch 0 taken 772 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 772 times.
✗ Branch 3 not taken.
772 if(!p_getc(&tempMsgString.margins[q],f))
4141 {
4142 return qe_invalid;
4143 }
4144 772 }
4145
4146
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_igetl(&tempMsgString.portrait_tile,f))
4147 {
4148 return qe_invalid;
4149 }
4150
4151
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&tempMsgString.portrait_cset,f))
4152 {
4153 return qe_invalid;
4154 }
4155
4156
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&tempMsgString.portrait_x,f))
4157 {
4158 return qe_invalid;
4159 }
4160
4161
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&tempMsgString.portrait_y,f))
4162 {
4163 return qe_invalid;
4164 }
4165
4166
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&tempMsgString.portrait_tw,f))
4167 {
4168 return qe_invalid;
4169 }
4170
4171
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&tempMsgString.portrait_th,f))
4172 {
4173 return qe_invalid;
4174 }
4175 193 }
4176
4177
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 7038 times.
7231 if(s_version >= 8)
4178 {
4179
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&tempMsgString.shadow_type,f))
4180 {
4181 return qe_invalid;
4182 }
4183
4184
2/4
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193 times.
✗ Branch 3 not taken.
193 if(!p_getc(&tempMsgString.shadow_color,f))
4185 {
4186 return qe_invalid;
4187 }
4188 193 }
4189
4190
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 7155 times.
7231 if(s_version >= 10)
4191 {
4192
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 if(!p_getc(&tempMsgString.drawlayer,f))
4193 {
4194 return qe_invalid;
4195 }
4196 76 }
4197
4198
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_getc(&tempMsgString.sfx,f))
4199 {
4200 return qe_invalid;
4201 }
4202
4203
1/2
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
7231 if(s_version>3)
4204 {
4205
2/4
✓ Branch 0 taken 7231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7231 times.
✗ Branch 3 not taken.
7231 if(!p_igetw(&tempMsgString.listpos,f))
4206 {
4207 return qe_invalid;
4208 }
4209 7231 }
4210 }
4211
4212
1/2
✓ Branch 0 taken 26332 times.
✗ Branch 1 not taken.
26332 MsgStrings[i].copyAll(tempMsgString);
4213 26332 }
4214 }
4215
4216 129 msg_count=temp_msg_count;
4217
4218 129 return 0;
4219 129 }
4220
4221 129 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4222 {
4223
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
4224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4225 {
4226 4 return 0;
4227 }
4228
4229 125 word temp_door_combo_set_count=0;
4230 DoorComboSet tempDoorComboSet;
4231 word dummy_word;
4232 int32_t dummy_long;
4233 byte padding;
4234 125 int32_t s_version = 0;
4235
4236
2/2
✓ Branch 0 taken 32000 times.
✓ Branch 1 taken 125 times.
32125 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4237 {
4238 32000 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4239 32000 }
4240
4241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(Header->zelda_version > 0x192)
4242 {
4243 //section version info
4244
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
4245 {
4246 return qe_invalid;
4247 }
4248
4249 125 FFCore.quest_format[vDoors] = s_version;
4250
4251 //al_trace("Door combo sets version %d\n", dummy_word);
4252
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy_word,f))
4253 {
4254 return qe_invalid;
4255 }
4256
4257 //section size
4258
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy_long,f))
4259 {
4260 return qe_invalid;
4261 }
4262 125 }
4263
4264 //finally... section data
4265
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_door_combo_set_count,f))
4266 {
4267 return qe_invalid;
4268 }
4269
4270
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4271 {
4272 return qe_invalid;
4273 }
4274
4275
2/2
✓ Branch 0 taken 978 times.
✓ Branch 1 taken 125 times.
1103 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4276 {
4277 978 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4278
4279 //name
4280
1/2
✓ Branch 0 taken 978 times.
✗ Branch 1 not taken.
978 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4281 {
4282 return qe_invalid;
4283 }
4284
4285
1/2
✓ Branch 0 taken 978 times.
✗ Branch 1 not taken.
978 if(Header->zelda_version < 0x193)
4286 {
4287 if(!p_getc(&padding,f))
4288 {
4289 return qe_invalid;
4290 }
4291 }
4292
4293 //up door
4294
2/2
✓ Branch 0 taken 8802 times.
✓ Branch 1 taken 978 times.
9780 for(int32_t j=0; j<9; j++)
4295 {
4296
2/2
✓ Branch 0 taken 35208 times.
✓ Branch 1 taken 8802 times.
44010 for(int32_t k=0; k<4; k++)
4297 {
4298
1/2
✓ Branch 0 taken 35208 times.
✗ Branch 1 not taken.
35208 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4299 {
4300 return qe_invalid;
4301 }
4302 35208 }
4303 8802 }
4304
4305
2/2
✓ Branch 0 taken 8802 times.
✓ Branch 1 taken 978 times.
9780 for(int32_t j=0; j<9; j++)
4306 {
4307
2/2
✓ Branch 0 taken 35208 times.
✓ Branch 1 taken 8802 times.
44010 for(int32_t k=0; k<4; k++)
4308 {
4309
1/2
✓ Branch 0 taken 35208 times.
✗ Branch 1 not taken.
35208 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4310 {
4311 return qe_invalid;
4312 }
4313 35208 }
4314 8802 }
4315
4316 //down door
4317
2/2
✓ Branch 0 taken 8802 times.
✓ Branch 1 taken 978 times.
9780 for(int32_t j=0; j<9; j++)
4318 {
4319
2/2
✓ Branch 0 taken 35208 times.
✓ Branch 1 taken 8802 times.
44010 for(int32_t k=0; k<4; k++)
4320 {
4321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35208 times.
35208 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4322 {
4323 return qe_invalid;
4324 }
4325 35208 }
4326 8802 }
4327
4328
2/2
✓ Branch 0 taken 8802 times.
✓ Branch 1 taken 978 times.
9780 for(int32_t j=0; j<9; j++)
4329 {
4330
2/2
✓ Branch 0 taken 35208 times.
✓ Branch 1 taken 8802 times.
44010 for(int32_t k=0; k<4; k++)
4331 {
4332
1/2
✓ Branch 0 taken 35208 times.
✗ Branch 1 not taken.
35208 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4333 {
4334 return qe_invalid;
4335 }
4336 35208 }
4337 8802 }
4338
4339 //left door
4340
2/2
✓ Branch 0 taken 8802 times.
✓ Branch 1 taken 978 times.
9780 for(int32_t j=0; j<9; j++)
4341 {
4342
2/2
✓ Branch 0 taken 52812 times.
✓ Branch 1 taken 8802 times.
61614 for(int32_t k=0; k<6; k++)
4343 {
4344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52812 times.
52812 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4345 {
4346 return qe_invalid;
4347 }
4348 52812 }
4349 8802 }
4350
4351
2/2
✓ Branch 0 taken 8802 times.
✓ Branch 1 taken 978 times.
9780 for(int32_t j=0; j<9; j++)
4352 {
4353
2/2
✓ Branch 0 taken 52812 times.
✓ Branch 1 taken 8802 times.
61614 for(int32_t k=0; k<6; k++)
4354 {
4355
1/2
✓ Branch 0 taken 52812 times.
✗ Branch 1 not taken.
52812 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4356 {
4357 return qe_invalid;
4358 }
4359 52812 }
4360 8802 }
4361
4362 //right door
4363
2/2
✓ Branch 0 taken 8802 times.
✓ Branch 1 taken 978 times.
9780 for(int32_t j=0; j<9; j++)
4364 {
4365
2/2
✓ Branch 0 taken 52812 times.
✓ Branch 1 taken 8802 times.
61614 for(int32_t k=0; k<6; k++)
4366 {
4367
1/2
✓ Branch 0 taken 52812 times.
✗ Branch 1 not taken.
52812 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4368 {
4369 return qe_invalid;
4370 }
4371 52812 }
4372 8802 }
4373
4374
2/2
✓ Branch 0 taken 8802 times.
✓ Branch 1 taken 978 times.
9780 for(int32_t j=0; j<9; j++)
4375 {
4376
2/2
✓ Branch 0 taken 52812 times.
✓ Branch 1 taken 8802 times.
61614 for(int32_t k=0; k<6; k++)
4377 {
4378
1/2
✓ Branch 0 taken 52812 times.
✗ Branch 1 not taken.
52812 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4379 {
4380 return qe_invalid;
4381 }
4382 52812 }
4383 8802 }
4384
4385 //up bomb rubble
4386
2/2
✓ Branch 0 taken 1956 times.
✓ Branch 1 taken 978 times.
2934 for(int32_t j=0; j<2; j++)
4387 {
4388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1956 times.
1956 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4389 {
4390 return qe_invalid;
4391 }
4392 1956 }
4393
4394
2/2
✓ Branch 0 taken 1956 times.
✓ Branch 1 taken 978 times.
2934 for(int32_t j=0; j<2; j++)
4395 {
4396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1956 times.
1956 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4397 {
4398 return qe_invalid;
4399 }
4400 1956 }
4401
4402 //down bomb rubble
4403
2/2
✓ Branch 0 taken 1956 times.
✓ Branch 1 taken 978 times.
2934 for(int32_t j=0; j<2; j++)
4404 {
4405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1956 times.
1956 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4406 {
4407 return qe_invalid;
4408 }
4409 1956 }
4410
4411
2/2
✓ Branch 0 taken 1956 times.
✓ Branch 1 taken 978 times.
2934 for(int32_t j=0; j<2; j++)
4412 {
4413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1956 times.
1956 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4414 {
4415 return qe_invalid;
4416 }
4417 1956 }
4418
4419 //left bomb rubble
4420
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 978 times.
3912 for(int32_t j=0; j<3; j++)
4421 {
4422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2934 times.
2934 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4423 {
4424 return qe_invalid;
4425 }
4426 2934 }
4427
4428
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 978 times.
3912 for(int32_t j=0; j<3; j++)
4429 {
4430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2934 times.
2934 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4431 {
4432 return qe_invalid;
4433 }
4434 2934 }
4435
4436
1/2
✓ Branch 0 taken 978 times.
✗ Branch 1 not taken.
978 if(Header->zelda_version < 0x193)
4437 {
4438 if(!p_getc(&padding,f))
4439 {
4440 return qe_invalid;
4441 }
4442
4443 }
4444
4445 //right bomb rubble
4446
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 978 times.
3912 for(int32_t j=0; j<3; j++)
4447 {
4448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2934 times.
2934 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4449 {
4450 return qe_invalid;
4451 }
4452 2934 }
4453
4454
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 978 times.
3912 for(int32_t j=0; j<3; j++)
4455 {
4456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2934 times.
2934 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4457 {
4458 return qe_invalid;
4459 }
4460 2934 }
4461
4462
1/2
✓ Branch 0 taken 978 times.
✗ Branch 1 not taken.
978 if(Header->zelda_version < 0x193)
4463 {
4464 if(!p_getc(&padding,f))
4465 {
4466 return qe_invalid;
4467 }
4468 }
4469
4470 //walkthrough stuff
4471
2/2
✓ Branch 0 taken 3912 times.
✓ Branch 1 taken 978 times.
4890 for(int32_t j=0; j<4; j++)
4472 {
4473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3912 times.
3912 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4474 {
4475 return qe_invalid;
4476 }
4477 3912 }
4478
4479
2/2
✓ Branch 0 taken 3912 times.
✓ Branch 1 taken 978 times.
4890 for(int32_t j=0; j<4; j++)
4480 {
4481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3912 times.
3912 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4482 {
4483 return qe_invalid;
4484 }
4485 3912 }
4486
4487 //flags
4488
2/2
✓ Branch 0 taken 1956 times.
✓ Branch 1 taken 978 times.
2934 for(int32_t j=0; j<2; j++)
4489 {
4490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1956 times.
1956 if(!p_getc(&tempDoorComboSet.flags[j],f))
4491 {
4492 return qe_invalid;
4493 }
4494 1956 }
4495
4496
1/2
✓ Branch 0 taken 978 times.
✗ Branch 1 not taken.
978 if(Header->zelda_version < 0x193)
4497 {
4498 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4499 {
4500 return qe_invalid;
4501 }
4502 }
4503
4504 978 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4505 978 }
4506
4507 125 door_combo_set_count=temp_door_combo_set_count;
4508
4509 125 return 0;
4510 129 }
4511
4512 int32_t count_dmaps()
4513 {
4514 int32_t i=MAXDMAPS-1;
4515 bool found=false;
4516
4517 while(i>=0 && !found)
4518 {
4519 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4520 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4521 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4522 found=true;
4523
4524 for(int32_t j=0; j<8; j++)
4525 {
4526 if(DMaps[i].grid[j]!=0)
4527
4528 found=true;
4529 }
4530
4531 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4532 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4533 found=true;
4534
4535 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4536 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4537 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4538 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4539 found=true;
4540
4541 if(!found)
4542 {
4543 i--;
4544 }
4545 }
4546
4547 return i+1;
4548 }
4549
4550
4551 int32_t count_shops(miscQdata *Misc)
4552 {
4553 int32_t i=NUM_SHOPS-1,j;
4554 bool found=false;
4555
4556 while(i>=0 && !found)
4557 {
4558 j=2;
4559
4560 while(j>=0 && !found)
4561 {
4562 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4563 {
4564 found=true;
4565 }
4566 else
4567 {
4568 j--;
4569 }
4570 }
4571
4572 if(Misc->shop[i].name[0]!=0)
4573 {
4574 found=true;
4575 }
4576
4577 if(!found)
4578 {
4579 i--;
4580 }
4581 }
4582
4583 return i+1;
4584 }
4585
4586 int32_t count_infos(miscQdata *Misc)
4587 {
4588 int32_t i=255,j;
4589 bool found=false;
4590
4591 while(i>=0 && !found)
4592 {
4593 j=2;
4594
4595 while(j>=0 && !found)
4596 {
4597 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4598 {
4599 found=true;
4600 }
4601 else
4602 {
4603 j--;
4604 }
4605 }
4606
4607 if(Misc->info[i].name[0]!=0)
4608 {
4609 found=true;
4610 }
4611
4612 if(!found)
4613 {
4614 i--;
4615 }
4616 }
4617
4618 return i+1;
4619 }
4620
4621 int32_t count_warprings(miscQdata *Misc)
4622 {
4623 int32_t i=15,j;
4624 bool found=false;
4625
4626 while(i>=0 && !found)
4627 {
4628 j=7;
4629
4630 while(j>=0 && !found)
4631 {
4632 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4633 {
4634 found=true;
4635 }
4636 else
4637 {
4638 j--;
4639 }
4640 }
4641
4642 if(!found)
4643 {
4644 i--;
4645 }
4646 }
4647
4648 return i+1;
4649 }
4650
4651 int32_t count_palcycles(miscQdata *Misc)
4652 {
4653 int32_t i=255,j;
4654 bool found=false;
4655
4656 while(i>=0 && !found)
4657 {
4658 j=2;
4659
4660 while(j>=0 && !found)
4661 {
4662 if(Misc->cycles[i][j].count!=0)
4663 {
4664 found=true;
4665 }
4666 else
4667 {
4668 j--;
4669 }
4670 }
4671
4672 if(!found)
4673 {
4674 i--;
4675 }
4676 }
4677
4678 return i+1;
4679 }
4680
4681 258185 void clear_screen(mapscr *temp_scr)
4682 {
4683 258185 temp_scr->zero_memory();
4684 258185 }
4685
4686 129 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4687 {
4688 129 word dmapstoread=0;
4689 dmap tempDMap;
4690
4691 int32_t dummy;
4692 129 word s_version=0, s_cversion=0;
4693 byte padding;
4694
4695
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<max_dmaps; i++)
4696 {
4697 66048 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4698 66048 sprintf(DMaps[start_dmap+i].title," ");
4699 66048 sprintf(DMaps[start_dmap+i].intro," ");
4700 66048 DMaps[start_dmap+i].type |= dmCAVE;
4701 66048 }
4702
4703
3/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 4 times.
129 if(!Header || Header->zelda_version > 0x192)
4704 {
4705 //section version info
4706
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
4707 {
4708 return qe_invalid;
4709 }
4710
4711 125 FFCore.quest_format[vDMaps] = s_version;
4712
4713 //al_trace("DMaps version %d\n", s_version);
4714
4715
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
4716 {
4717 return qe_invalid;
4718 }
4719
4720 //section size
4721
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
4722 {
4723 return qe_invalid;
4724 }
4725
4726 //finally... section data
4727
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dmapstoread,f))
4728 {
4729 return qe_invalid;
4730 }
4731 125 }
4732 else
4733 {
4734
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4735 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4736 {
4737 4 dmapstoread=32;
4738 4 }
4739 else if(s_version <= 4)
4740 {
4741 dmapstoread=OLDMAXDMAPS;
4742 }
4743 else
4744 {
4745 dmapstoread=MAXDMAPS;
4746 }
4747 }
4748
4749
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 dmapstoread=zc_min(dmapstoread, max_dmaps);
4750
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4751
4752
2/2
✓ Branch 0 taken 61056 times.
✓ Branch 1 taken 129 times.
61185 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4753 {
4754 61056 memset(&tempDMap,0,sizeof(dmap));
4755 61056 sprintf(tempDMap.title," ");
4756 61056 sprintf(tempDMap.intro," ");
4757
4758
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.map,f))
4759 {
4760 return qe_invalid;
4761 }
4762
4763
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version <= 4)
4764 {
4765 byte tempbyte;
4766
4767
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4768 {
4769 return qe_invalid;
4770 }
4771
4772 3200 tempDMap.level=(word)tempbyte;
4773 3200 }
4774 else
4775 {
4776
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&tempDMap.level,f))
4777 {
4778 return qe_invalid;
4779 }
4780 }
4781
4782
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.xoff,f))
4783 {
4784 return qe_invalid;
4785 }
4786
4787
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.compass,f))
4788 {
4789 return qe_invalid;
4790 }
4791
4792
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version > 8) // February 2009
4793 {
4794
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&tempDMap.color,f))
4795 {
4796 return qe_invalid;
4797 }
4798 57856 }
4799 else
4800 {
4801 byte tempbyte;
4802
4803
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4804 {
4805 return qe_invalid;
4806 }
4807
4808 3200 tempDMap.color = (word)tempbyte;
4809 }
4810
4811
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.midi,f))
4812 {
4813 return qe_invalid;
4814 }
4815
4816
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.cont,f))
4817 {
4818 return qe_invalid;
4819 }
4820
4821
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.type,f))
4822 {
4823 return qe_invalid;
4824 }
4825
4826
4/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 60240 times.
✓ Branch 2 taken 804 times.
✓ Branch 3 taken 12 times.
61872 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4827
1/2
✓ Branch 0 taken 816 times.
✗ Branch 1 not taken.
816 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4828 804 tempDMap.xoff = 0;
4829
4830
2/2
✓ Branch 0 taken 488448 times.
✓ Branch 1 taken 61056 times.
549504 for(int32_t j=0; j<8; j++)
4831 {
4832
1/2
✓ Branch 0 taken 488448 times.
✗ Branch 1 not taken.
488448 if(!p_getc(&tempDMap.grid[j],f))
4833 {
4834 return qe_invalid;
4835 }
4836 488448 }
4837
4838
4/8
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60928 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61056 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4839 {
4840
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4841 {
4842 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4843 38 }
4844
4845
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4846 {
4847 4 tempDMap.cont-=tempDMap.xoff;
4848 4 tempDMap.compass-=tempDMap.xoff;
4849 4 }
4850
4851 //forgotten -DD
4852
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4853 {
4854 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4855 90 }
4856 128 }
4857 else
4858 {
4859
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f))
4860 {
4861 return qe_invalid;
4862 }
4863
4864
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f))
4865 {
4866 return qe_invalid;
4867 }
4868
4869
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f))
4870 {
4871 return qe_invalid;
4872 }
4873
4874
3/8
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 60928 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
60928 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4875 {
4876 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4877 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4878
4879 continue;
4880 }
4881
4882
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4883 {
4884 if(!p_getc(&padding,f))
4885 {
4886 return qe_invalid;
4887 }
4888 }
4889
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4890 {
4891
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4892 {
4893 return qe_invalid;
4894 }
4895 18432 }
4896 else
4897 {
4898
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4899 {
4900 return qe_invalid;
4901 }
4902 }
4903
4904
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.minimap_1_cset,f))
4905 {
4906 return qe_invalid;
4907 }
4908
4909
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4910 {
4911 if(!p_getc(&padding,f))
4912 {
4913 return qe_invalid;
4914 }
4915 }
4916
4917
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4918 {
4919
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4920 {
4921 return qe_invalid;
4922 }
4923 18432 }
4924 else
4925 {
4926
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4927 {
4928 return qe_invalid;
4929 }
4930 }
4931
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.minimap_2_cset,f))
4932 {
4933 return qe_invalid;
4934 }
4935
4936
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4937 {
4938 if(!p_getc(&padding,f))
4939 {
4940 return qe_invalid;
4941 }
4942 }
4943
4944
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4945 {
4946
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4947 {
4948 return qe_invalid;
4949 }
4950 18432 }
4951 else
4952 {
4953
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4954 {
4955 return qe_invalid;
4956 }
4957 }
4958
4959
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.largemap_1_cset,f))
4960 {
4961 return qe_invalid;
4962 }
4963
4964
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4965 {
4966
4967 if(!p_getc(&padding,f))
4968 {
4969 return qe_invalid;
4970 }
4971 }
4972
4973
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4974 {
4975
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4976 {
4977 return qe_invalid;
4978 }
4979 18432 }
4980 else
4981 {
4982
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4983 {
4984 return qe_invalid;
4985 }
4986 }
4987
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.largemap_2_cset,f))
4988 {
4989 return qe_invalid;
4990 }
4991
4992
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f))
4993 {
4994 return qe_invalid;
4995 }
4996 }
4997
4998
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version>1)
4999 {
5000
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.tmusictrack,f))
5001 {
5002 return qe_invalid;
5003 }
5004
5005
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.active_subscreen,f))
5006 {
5007 return qe_invalid;
5008 }
5009
5010
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.passive_subscreen,f))
5011 {
5012 return qe_invalid;
5013 }
5014 57856 }
5015
5016
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version>2)
5017 {
5018 byte di[32];
5019
5020
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(&di, 32, f)) return qe_invalid;
5021
5022
2/2
✓ Branch 0 taken 14811136 times.
✓ Branch 1 taken 57856 times.
14868992 for(int32_t j=0; j<MAXITEMS; j++)
5023 {
5024
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14811129 times.
14811136 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
5025 14811129 else tempDMap.disableditems[j]=0;
5026 14811136 }
5027 57856 }
5028
5029
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version >= 6)
5030 {
5031
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&tempDMap.flags,f))
5032 {
5033 return qe_invalid;
5034 }
5035 57856 }
5036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 else if(s_version>3)
5037 {
5038 char temp;
5039
5040 if(!p_getc(&temp,f))
5041 {
5042 return qe_invalid;
5043 }
5044
5045 tempDMap.flags = temp;
5046 }
5047
3/8
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3200 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
5048 {
5049 816 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
5050 816 }
5051 else
5052 2384 tempDMap.flags=0;
5053
5054
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version<7)
5055 {
5056
3/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
3200 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
5057 816 tempDMap.flags|= dmfVIEWMAP;
5058 3200 }
5059
5060
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version<8)
5061 {
5062
4/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 609 times.
3200 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5063 {
5064 609 tempDMap.type &= ~dmDNGN;
5065 609 tempDMap.type |= dmCAVE;
5066 609 }
5067
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1736 times.
2591 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5068 {
5069 1736 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5070 1736 }
5071 3200 }
5072
5073
5/8
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 60928 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 60928 times.
✗ Branch 7 not taken.
61056 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5074 60928 && (Header->zelda_version < 0x193))
5075 {
5076 if(!p_getc(&padding,f))
5077 {
5078 return qe_invalid;
5079 }
5080 }
5081
5082
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 10)
5083 {
5084
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempDMap.sideview,f))
5085 {
5086 return qe_invalid;
5087 }
5088 18432 }
5089
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version < 10) tempDMap.sideview = 0;
5090
5091 //Dmap Scripts
5092
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 12)
5093 {
5094
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.script,f))
5095 {
5096 return qe_invalid;
5097 }
5098
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
5099 {
5100
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.initD[q],f))
5101 {
5102 return qe_invalid;
5103 }
5104 147456 }
5105 18432 }
5106
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if ( s_version < 12 )
5107 {
5108 42624 tempDMap.script = 0;
5109
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5110 {
5111 340992 tempDMap.initD[q] = 0;
5112 340992 }
5113 42624 }
5114
5115
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 13)
5116 {
5117
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
5118 {
5119
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
5120 {
5121
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.initD_label[q][w],f))
5122 {
5123 return qe_invalid;
5124 }
5125 9584640 }
5126 147456 }
5127 18432 }
5128
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if ( s_version < 13 )
5129 {
5130 42624 tempDMap.script = 0;
5131
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5132 {
5133
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for ( int32_t w = 0; w < 65; w++ )
5134 22164480 tempDMap.initD_label[q][w] = 0;
5135 340992 }
5136 42624 }
5137
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 14)
5138 {
5139
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.active_sub_script,f))
5140 {
5141 return qe_invalid;
5142 }
5143
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.passive_sub_script,f))
5144 {
5145 return qe_invalid;
5146 }
5147
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; ++q )
5148 {
5149
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.sub_initD[q],f))
5150 {
5151 return qe_invalid;
5152 }
5153 147456 }
5154
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for(int32_t q = 0; q < 8; ++q)
5155 {
5156
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; ++w )
5157 {
5158
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5159 {
5160 return qe_invalid;
5161 }
5162 9584640 }
5163 147456 }
5164 18432 }
5165 else
5166 {
5167 42624 tempDMap.active_sub_script = 0;
5168 42624 tempDMap.passive_sub_script = 0;
5169
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5170 {
5171 340992 tempDMap.sub_initD[q] = 0;
5172
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5173 22164480 tempDMap.sub_initD_label[q][w] = 0;
5174 340992 }
5175 }
5176
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 15)
5177 {
5178
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.onmap_script,f))
5179 {
5180 return qe_invalid;
5181 }
5182
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; ++q )
5183 {
5184
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5185 {
5186 return qe_invalid;
5187 }
5188 147456 }
5189
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for(int32_t q = 0; q < 8; ++q)
5190 {
5191
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; ++w )
5192 {
5193
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5194 {
5195 return qe_invalid;
5196 }
5197 9584640 }
5198 147456 }
5199 18432 }
5200 else
5201 {
5202 42624 tempDMap.onmap_script = 0;
5203
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5204 {
5205 340992 tempDMap.onmap_initD[q] = 0;
5206
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5207 {
5208 22164480 tempDMap.onmap_initD_label[q][w] = 0;
5209 22164480 }
5210 340992 }
5211 }
5212
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 16)
5213 {
5214
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.mirrorDMap,f))
5215 {
5216 return qe_invalid;
5217 }
5218 18432 }
5219 else
5220 {
5221 42624 tempDMap.mirrorDMap = -1;
5222 }
5223
5224
2/2
✓ Branch 0 taken 46720 times.
✓ Branch 1 taken 14336 times.
61056 if (s_version >= 17)
5225 {
5226 // Reserved for z3.
5227 14336 }
5228
5229 // Enhanced music loop points
5230
2/2
✓ Branch 0 taken 14336 times.
✓ Branch 1 taken 46720 times.
61056 if (s_version >= 18)
5231 {
5232
1/2
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
14336 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5233 {
5234 return qe_invalid;
5235 }
5236
1/2
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
14336 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5237 {
5238 return qe_invalid;
5239 }
5240
1/2
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
14336 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5241 {
5242 return qe_invalid;
5243 }
5244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5245 {
5246 return qe_invalid;
5247 }
5248 14336 }
5249 else
5250 {
5251 46720 tempDMap.tmusic_loop_start = 0;
5252 46720 tempDMap.tmusic_loop_end = 0;
5253 46720 tempDMap.tmusic_xfade_in = 0;
5254 46720 tempDMap.tmusic_xfade_out = 0;
5255 }
5256
5257
2/2
✓ Branch 0 taken 46720 times.
✓ Branch 1 taken 14336 times.
61056 if(s_version >= 19)
5258
1/2
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
14336 if(!p_getc(&tempDMap.overlay_subscreen, f))
5259 return qe_invalid;
5260
5261 61056 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5262 61056 }
5263
5264 129 return 0;
5265 129 }
5266
5267 113 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5268 {
5269 //these are here to bypass compiler warnings about unused arguments
5270 113 Header=Header;
5271
5272 miscQdata temp_misc;
5273 113 word s_version=0, s_cversion=0;
5274 113 int32_t tempsize=0;
5275 word dummyw;
5276
5277 113 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5278
5279 //section version info
5280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
5281 {
5282 return qe_invalid;
5283 }
5284
5285 113 FFCore.quest_format[vColours] = s_version;
5286
5287 113 al_trace("Misc Colours section version: %d\n", s_version);
5288
5289 //al_trace("Misc. colors version %d\n", s_version);
5290
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
5291 {
5292 return qe_invalid;
5293 }
5294
5295
5296 //section size
5297
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&tempsize,f))
5298 {
5299 return qe_invalid;
5300 }
5301
5302 //finally... section data
5303 113 readsize=0;
5304
5305
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.text,f))
5306 {
5307 return qe_invalid;
5308 }
5309
5310
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.caption,f))
5311 {
5312 return qe_invalid;
5313 }
5314
5315
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.overw_bg,f))
5316 {
5317 return qe_invalid;
5318 }
5319
5320
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5321 {
5322 return qe_invalid;
5323 }
5324
5325
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5326 {
5327 return qe_invalid;
5328 }
5329
5330
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.cave_fg,f))
5331 {
5332 return qe_invalid;
5333 }
5334
5335
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bs_dk,f))
5336 {
5337 return qe_invalid;
5338 }
5339
5340
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bs_goal,f))
5341 {
5342 return qe_invalid;
5343 }
5344
5345
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.compass_lt,f))
5346 {
5347 return qe_invalid;
5348 }
5349
5350
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.compass_dk,f))
5351 {
5352 return qe_invalid;
5353 }
5354
5355
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5356 {
5357 return qe_invalid;
5358 }
5359
5360
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triframe_color,f))
5361 {
5362 return qe_invalid;
5363 }
5364
5365
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.hero_dot,f))
5366 {
5367 return qe_invalid;
5368 }
5369
5370
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5371 {
5372 return qe_invalid;
5373 }
5374
5375
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5376 {
5377 return qe_invalid;
5378 }
5379
5380
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5381 {
5382 return qe_invalid;
5383 }
5384
5385
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5386 {
5387 return qe_invalid;
5388 }
5389
5390
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5391 {
5392 return qe_invalid;
5393 }
5394
5395
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5396 {
5397 return qe_invalid;
5398 }
5399
5400
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5401 {
5402 return qe_invalid;
5403 }
5404
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version < 4)
5405 {
5406
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5407 return qe_invalid;
5408 77 temp_misc.colors.triforce_tile = dummyw;
5409
5410
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5411 return qe_invalid;
5412 77 temp_misc.colors.triframe_tile = dummyw;
5413
5414
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5415 return qe_invalid;
5416 77 temp_misc.colors.overworld_map_tile = dummyw;
5417
5418
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5419 return qe_invalid;
5420 77 temp_misc.colors.dungeon_map_tile = dummyw;
5421
5422
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5423 return qe_invalid;
5424 77 temp_misc.colors.blueframe_tile = dummyw;
5425
5426
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5427 return qe_invalid;
5428 77 temp_misc.colors.HCpieces_tile = dummyw;
5429 77 }
5430
5431
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5432 {
5433 return qe_invalid;
5434 }
5435
5436
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5437 {
5438 return qe_invalid;
5439 }
5440
5441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version < 2)
5442 {
5443 temp_misc.colors.msgtext = 0x01;
5444 }
5445 else
5446 {
5447
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.msgtext, f))
5448 {
5449 return qe_invalid;
5450 }
5451 }
5452
5453
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if ( s_version >= 3 ) //expanded tile pages to 825
5454 {
5455
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5456 {
5457 return qe_invalid;
5458 }
5459
5460
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5461 {
5462 return qe_invalid;
5463 }
5464
5465
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5466 {
5467 return qe_invalid;
5468 }
5469
5470
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5471 {
5472 return qe_invalid;
5473 }
5474
5475
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5476 {
5477 return qe_invalid;
5478 }
5479
5480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5481 {
5482 return qe_invalid;
5483 }
5484 36 }
5485
5486 113 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5487
5488 113 return 0;
5489 113 }
5490
5491 113 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5492 {
5493 miscQdata temp_misc;
5494 113 word s_version=0, s_cversion=0;
5495 byte icons;
5496 113 int32_t tempsize=0;
5497
5498 113 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5499
5500 //section version info
5501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
5502 {
5503 return qe_invalid;
5504 }
5505
5506 113 FFCore.quest_format[vIcons] = s_version;
5507
5508 //al_trace("Game icons version %d\n", s_version);
5509
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
5510 {
5511 return qe_invalid;
5512 }
5513
5514
5515 //section size
5516
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&tempsize,f))
5517 {
5518 return qe_invalid;
5519 }
5520
5521 //finally... section data
5522 113 readsize=0;
5523
5524 113 icons=4;
5525
5526
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if ( s_version >= 10 )
5527 {
5528
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<icons; i++)
5529 {
5530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&temp_misc.icons[i],f))
5531 {
5532 return qe_invalid;
5533 }
5534 144 }
5535 36 }
5536 else
5537 {
5538
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<icons; i++)
5539 {
5540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_igetw(&temp_misc.icons[i],f))
5541 {
5542 return qe_invalid;
5543 }
5544 308 }
5545 }
5546
5547 113 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5548
5549 113 return 0;
5550 113 }
5551
5552 129 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5553 {
5554 129 word maxinfos=256;
5555 129 word maxshops=256;
5556 129 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5557 129 word ponds=16, pondsize=72, expansionsize=98*2;
5558 byte tempbyte, padding;
5559 miscQdata temp_misc;
5560 129 word s_version=0, s_cversion=0;
5561 word swaptmp;
5562 129 int32_t tempsize=0;
5563
5564 129 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5565
5566
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxshops; ++i)
5567 {
5568 33024 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5569 33024 }
5570
5571
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxinfos; ++i)
5572 {
5573 33024 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5574 33024 }
5575
5576
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5577 {
5578 //section version info
5579
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
5580 {
5581 return qe_invalid;
5582 }
5583
5584 125 FFCore.quest_format[vMisc] = s_version;
5585
5586 //al_trace("Misc. data version %d\n", s_version);
5587
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
5588 {
5589 return qe_invalid;
5590 }
5591
5592
5593 //section size
5594
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&tempsize,f))
5595 {
5596 return qe_invalid;
5597 }
5598 125 }
5599
5600 //finally... section data
5601 129 readsize=0;
5602
5603 //shops
5604
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5605 {
5606
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&shops,f))
5607 {
5608 return qe_invalid;
5609 }
5610 125 }
5611
5612
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(shops >= 0 && shops <= NUM_SHOPS))
5613 {
5614 return qe_invalid;
5615 }
5616
5617
2/2
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 129 times.
1601 for(int32_t i=0; i<shops; i++)
5618 {
5619
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1249 times.
1472 if(s_version > 6)
5620 {
5621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1249 times.
1249 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f))
5622 {
5623 return qe_invalid;
5624 }
5625 1249 }
5626
5627
2/2
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 1472 times.
5888 for(int32_t j=0; j<3; j++)
5628 {
5629
1/2
✓ Branch 0 taken 4416 times.
✗ Branch 1 not taken.
4416 if(!p_getc(&temp_misc.shop[i].item[j],f))
5630 {
5631 return qe_invalid;
5632 }
5633
5634
2/2
✓ Branch 0 taken 3747 times.
✓ Branch 1 taken 669 times.
4416 if(s_version < 4)
5635 {
5636 669 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5637 669 }
5638 4416 }
5639
5640
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 64 times.
1472 if(Header->zelda_version < 0x193)
5641 {
5642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f))
5643 {
5644 return qe_invalid;
5645 }
5646 64 }
5647
5648
2/2
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 1472 times.
5888 for(int32_t j=0; j<3; j++)
5649 {
5650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4416 times.
4416 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5651 {
5652 return qe_invalid;
5653 }
5654 4416 }
5655
5656
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1249 times.
1472 if(s_version > 3)
5657 {
5658
2/2
✓ Branch 0 taken 3747 times.
✓ Branch 1 taken 1249 times.
4996 for(int32_t j=0; j<3; j++)
5659 {
5660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3747 times.
3747 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5661 return qe_invalid;
5662 3747 }
5663 1249 }
5664
5665 /*
5666 if(s_version < 8)
5667 {
5668 for(int32_t j=0; j<3; j++)
5669 {
5670 (&temp_misc.shop[i].str[j])=0; //initialise.
5671 }
5672 }
5673 */
5674 1472 }
5675
5676 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5677
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxshops; ++i)
5678 {
5679
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 33024 times.
99072 for(int32_t j=0; j<3-1; j++)
5680 {
5681
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 96063 times.
162111 for(int32_t k=0; k<2-j; k++)
5682 {
5683 96063 if(temp_misc.shop[i].hasitem[k]==0)
5684 {
5685 96063 swaptmp = temp_misc.shop[i].item[k];
5686 96063 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5687 96063 temp_misc.shop[i].item[k+1] = swaptmp;
5688 96063 swaptmp = temp_misc.shop[i].price[k];
5689 96063 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5690 96063 temp_misc.shop[i].price[k+1] = swaptmp;
5691 96063 swaptmp = temp_misc.shop[i].hasitem[k];
5692 96063 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5693 96063 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5694 96063 }
5695 96063 }
5696 66048 }
5697 33024 }
5698
5699 //infos
5700
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5701 {
5702
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&infos,f))
5703 {
5704 return qe_invalid;
5705 }
5706 125 }
5707
5708
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(infos >= 0 && infos <= NUM_INFOS))
5709 {
5710 return qe_invalid;
5711 }
5712
5713
5714
2/2
✓ Branch 0 taken 1783 times.
✓ Branch 1 taken 129 times.
1912 for(int32_t i=0; i<infos; i++)
5715 {
5716
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1683 times.
1783 if(s_version > 6)
5717 {
5718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1683 times.
1683 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f))
5719 {
5720 return qe_invalid;
5721 }
5722 1683 }
5723
5724
2/2
✓ Branch 0 taken 5349 times.
✓ Branch 1 taken 1783 times.
7132 for(int32_t j=0; j<3; j++)
5725 {
5726
2/4
✓ Branch 0 taken 5157 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5349 if((Header->zelda_version < 0x192)||
5727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5157 times.
5157 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5728 {
5729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5730 {
5731 return qe_invalid;
5732 }
5733
5734 192 temp_misc.info[i].str[j]=tempbyte;
5735 192 }
5736 else
5737 {
5738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5157 times.
5157 if(!p_igetw(&temp_misc.info[i].str[j],f))
5739 {
5740 return qe_invalid;
5741 }
5742 }
5743 5349 }
5744
5745
2/2
✓ Branch 0 taken 1719 times.
✓ Branch 1 taken 64 times.
1783 if(Header->zelda_version < 0x193)
5746 {
5747
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f))
5748 {
5749 return qe_invalid;
5750 }
5751 64 }
5752
5753
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1783 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1783 if((Header->zelda_version == 0x192)&&(Header->build>145))
5754 {
5755 if(!p_getc(&padding,f))
5756 {
5757 return qe_invalid;
5758 }
5759 }
5760
5761
2/2
✓ Branch 0 taken 5349 times.
✓ Branch 1 taken 1783 times.
7132 for(int32_t j=0; j<3; j++)
5762 {
5763
1/2
✓ Branch 0 taken 5349 times.
✗ Branch 1 not taken.
5349 if(!p_igetw(&temp_misc.info[i].price[j],f))
5764 {
5765 return qe_invalid;
5766 }
5767 5349 }
5768 1783 }
5769
5770 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5771
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxinfos; ++i)
5772 {
5773
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 33024 times.
99072 for(int32_t j=0; j<3-1; j++)
5774 {
5775
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 66048 times.
165120 for(int32_t k=0; k<2-j; k++)
5776 {
5777
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 96960 times.
99072 if(temp_misc.info[i].str[k]==0)
5778 {
5779 96960 swaptmp = temp_misc.info[i].str[k];
5780 96960 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5781 96960 temp_misc.info[i].str[k+1] = swaptmp;
5782 96960 swaptmp = temp_misc.info[i].price[k];
5783 96960 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5784 96960 temp_misc.info[i].price[k+1] = swaptmp;
5785 96960 }
5786 99072 }
5787 66048 }
5788 33024 }
5789
5790
5791 //warp rings
5792
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version > 5)
5793 113 warprings++;
5794
5795
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5796 {
5797
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&warprings,f))
5798 {
5799 return qe_invalid;
5800 }
5801
5802
3/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 38 times.
125 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5803 {
5804 // return qe_invalid;
5805 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5806 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5807 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5808 38 }
5809 125 }
5810
5811
2/2
✓ Branch 0 taken 1298 times.
✓ Branch 1 taken 129 times.
1427 for(int32_t i=0; i<warprings; i++)
5812 {
5813 // See above comment on the `warprings` range check.
5814 1298 bool keepdata = i < NUM_WARP_RINGS;
5815
5816
2/2
✓ Branch 0 taken 11458 times.
✓ Branch 1 taken 1298 times.
12756 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5817 {
5818
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 9666 times.
11458 if(s_version <= 3)
5819 {
5820
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(!p_getc(&tempbyte,f))
5821 {
5822 return qe_invalid;
5823 }
5824
5825
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1120 times.
1792 if (keepdata)
5826 1120 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5827 1792 }
5828 else
5829 {
5830 word tempword;
5831
1/2
✓ Branch 0 taken 9666 times.
✗ Branch 1 not taken.
9666 if(!p_igetw(&tempword,f))
5832 {
5833 return qe_invalid;
5834 }
5835
5836
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 9153 times.
9666 if (keepdata)
5837 9153 temp_misc.warp[i].dmap[j] = tempword;
5838 }
5839 11458 }
5840
5841
2/2
✓ Branch 0 taken 11458 times.
✓ Branch 1 taken 1298 times.
12756 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5842 {
5843
1/2
✓ Branch 0 taken 11458 times.
✗ Branch 1 not taken.
11458 if(!p_getc(&tempbyte,f))
5844 {
5845 return qe_invalid;
5846 }
5847
2/2
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 10273 times.
11458 if (keepdata)
5848 10273 temp_misc.warp[i].scr[j] = tempbyte;
5849 11458 }
5850
5851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1298 times.
1298 if(!p_getc(&tempbyte,f))
5852 {
5853 return qe_invalid;
5854 }
5855
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1157 times.
1298 if (keepdata)
5856 1157 temp_misc.warp[i].size = tempbyte;
5857
5858
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 32 times.
1298 if(Header->zelda_version < 0x193)
5859 {
5860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f))
5861 {
5862 return qe_invalid;
5863 }
5864 32 }
5865 1298 }
5866
5867 //palette cycles
5868
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5869 {
5870
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5871 {
5872
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5873 {
5874 3072 temp_misc.cycles[i][j].first=0;
5875 3072 temp_misc.cycles[i][j].count=0;
5876 3072 temp_misc.cycles[i][j].speed=0;
5877 3072 }
5878 1024 }
5879
5880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5881 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5882 {
5883 4 palcycles=16;
5884 4 }
5885
5886
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5887 {
5888
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5889 {
5890
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5891 {
5892 return qe_invalid;
5893 }
5894
5895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5896 {
5897 return qe_invalid;
5898 }
5899
5900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5901 {
5902 return qe_invalid;
5903 }
5904 192 }
5905 64 }
5906 4 }
5907
5908 //Wind warps are now just another warp ring.
5909
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version <= 5)
5910 {
5911
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(Header->zelda_version > 0x192)
5912 {
5913
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&windwarps,f))
5914 {
5915 return qe_invalid;
5916 }
5917 12 }
5918
5919
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5920 {
5921 return qe_invalid;
5922 }
5923
5924
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 16 times.
151 for(int32_t i=0; i<windwarps; i++)
5925 {
5926
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version <= 3)
5927 {
5928
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&tempbyte,f))
5929 {
5930 return qe_invalid;
5931 }
5932
5933 135 temp_misc.warp[8].dmap[i]=tempbyte;
5934 135 }
5935 else
5936 {
5937 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5938 {
5939 return qe_invalid;
5940 }
5941 }
5942
5943
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5944 {
5945 return qe_invalid;
5946 }
5947
5948 135 temp_misc.warp[8].size = 9;
5949
5950
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version == 5)
5951 {
5952 if(!p_getc(&tempbyte,f))
5953 {
5954 return qe_invalid;
5955 }
5956 }
5957 135 }
5958 16 }
5959
5960
5961 //triforce pieces
5962
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 129 times.
1161 for(int32_t i=0; i<triforces; i++)
5963 {
5964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
1032 if(!p_getc(&temp_misc.triforce[i],f))
5965 {
5966 return qe_invalid;
5967 }
5968 1032 }
5969
5970 //misc color data
5971
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<3)
5972 {
5973
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.text,f))
5974 {
5975 return qe_invalid;
5976 }
5977
5978
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.caption,f))
5979 {
5980 return qe_invalid;
5981 }
5982
5983
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overw_bg,f))
5984 {
5985 return qe_invalid;
5986 }
5987
5988
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5989 {
5990 return qe_invalid;
5991 }
5992
5993
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5994 {
5995 return qe_invalid;
5996 }
5997
5998
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.cave_fg,f))
5999 {
6000 return qe_invalid;
6001 }
6002
6003
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_dk,f))
6004 {
6005 return qe_invalid;
6006 }
6007
6008
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_goal,f))
6009 {
6010 return qe_invalid;
6011 }
6012
6013
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_lt,f))
6014 {
6015 return qe_invalid;
6016 }
6017
6018
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_dk,f))
6019 {
6020 return qe_invalid;
6021 }
6022
6023
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.subscr_bg,f))
6024 {
6025 return qe_invalid;
6026 }
6027
6028
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_color,f))
6029 {
6030 return qe_invalid;
6031 }
6032
6033
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.hero_dot,f))
6034 {
6035 return qe_invalid;
6036 }
6037
6038
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_bg,f))
6039 {
6040 return qe_invalid;
6041 }
6042
6043
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_fg,f))
6044 {
6045 return qe_invalid;
6046 }
6047
6048
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triforce_cset,f))
6049 {
6050 return qe_invalid;
6051 }
6052
6053
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_cset,f))
6054 {
6055 return qe_invalid;
6056 }
6057
6058
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
6059 {
6060 return qe_invalid;
6061 }
6062
6063
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
6064 {
6065 return qe_invalid;
6066 }
6067
6068
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
6069 {
6070 return qe_invalid;
6071 }
6072
6073
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
6074 {
6075 return qe_invalid;
6076 }
6077
6078
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
6079 {
6080 return qe_invalid;
6081 }
6082
6083
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
6084 {
6085 return qe_invalid;
6086 }
6087
6088
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
6089 {
6090 return qe_invalid;
6091 }
6092
6093
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6094 {
6095 return qe_invalid;
6096 }
6097
6098
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6099 {
6100 return qe_invalid;
6101 }
6102
6103
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6104 {
6105 return qe_invalid;
6106 }
6107
6108 16 temp_misc.colors.msgtext = 0x01;
6109
6110
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(Header->zelda_version < 0x193)
6111 {
6112
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6113 {
6114
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f))
6115 {
6116 return qe_invalid;
6117 }
6118 28 }
6119 4 }
6120
6121
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version == 0x192)&&(Header->build>145))
6122 {
6123 for(int32_t i=0; i<256; i++)
6124 {
6125 if(!p_getc(&tempbyte,f))
6126 {
6127 return qe_invalid;
6128 }
6129 }
6130 }
6131
6132
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(s_version>1)
6133 {
6134 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6135 {
6136 return qe_invalid;
6137 }
6138 }
6139
6140 //save game icons
6141
2/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version < 0x192)||
6142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6143 {
6144 4 icons=3;
6145 4 }
6146
6147
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 16 times.
76 for(int32_t i=0; i<icons; i++)
6148 {
6149
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&temp_misc.icons[i],f))
6150 {
6151 return qe_invalid;
6152 }
6153 60 }
6154 16 }
6155
6156
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
6157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6158 {
6159 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6160
6161 4 return 0;
6162 }
6163
6164 //pond information
6165
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
6166 {
6167 if((Header->zelda_version == 0x192)&&(Header->build<146))
6168 {
6169 pondsize=25;
6170 }
6171
6172 for(int32_t i=0; i<ponds; i++)
6173 {
6174 for(int32_t j=0; j<pondsize; j++)
6175 {
6176 if(!p_getc(&tempbyte,f))
6177 {
6178 return qe_invalid;
6179
6180 }
6181 }
6182 }
6183 }
6184
6185 //end string
6186
1/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version < 0x192)||
6187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6188 {
6189 if(!p_getc(&tempbyte,f))
6190 {
6191 return qe_invalid;
6192 }
6193
6194 temp_misc.endstring=tempbyte;
6195
6196 if(!p_getc(&tempbyte,f))
6197 {
6198 return qe_invalid;
6199 }
6200 }
6201 else
6202 {
6203
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_misc.endstring,f))
6204 {
6205 return qe_invalid;
6206 }
6207 }
6208
6209 //expansion
6210
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
6211 {
6212 if((Header->zelda_version == 0x192)&&(Header->build<73))
6213 {
6214 expansionsize=99*2;
6215 }
6216
6217 for(int32_t i=0; i<expansionsize; i++)
6218 {
6219 if(!p_getc(&tempbyte,f))
6220 {
6221 return qe_invalid;
6222 }
6223 }
6224 }
6225 //shops v8
6226
6227
6228
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version >= 8)
6229 {
6230
2/2
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 36 times.
580 for(int32_t i=0; i<shops; i++)
6231 {
6232
2/2
✓ Branch 0 taken 1632 times.
✓ Branch 1 taken 544 times.
2176 for(int32_t j=0; j<3; j++)
6233 {
6234
1/2
✓ Branch 0 taken 1632 times.
✗ Branch 1 not taken.
1632 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6235 return qe_invalid;
6236 1632 }
6237 544 }
6238 36 }
6239
6240 125 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6241 125 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6242 125 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6243
6244 //v9 includes quest misc[32]
6245
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version >= 9)
6246 {
6247
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 36 times.
1188 for ( int32_t q = 0; q < 32; q++ )
6248 {
6249
1/2
✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
1152 if(!p_igetl(&temp_misc.questmisc[q],f))
6250 return qe_invalid;
6251 1152 }
6252
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 36 times.
1188 for ( int32_t q = 0; q < 32; q++ )
6253 {
6254
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 1152 times.
148608 for ( int32_t j = 0; j < 128; j++ )
6255
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6256 return qe_invalid;
6257 1152 }
6258 36 }
6259
6260
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 11 )
6261 {
6262
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6263 return qe_invalid;
6264 36 }
6265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(s_version < 11 )
6266 {
6267 89 temp_misc.zscript_last_compiled_version = -1;
6268 89 }
6269
6270 125 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6271
6272
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 12)
6273 {
6274 byte spr;
6275
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t q = 0; q < sprMAX; ++q)
6276 {
6277
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&spr,f))
6278 return qe_invalid;
6279 9216 temp_misc.sprites[q] = spr;
6280 9216 }
6281 36 }
6282 else
6283 {
6284 89 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6285 //temp_misc.sprites[sprFALL] = ;
6286 }
6287
6288
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 13)
6289 {
6290
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 36 times.
2340 for(size_t q = 0; q < 64; ++q)
6291 {
6292 2304 bottletype* bt = &(temp_misc.bottle_types[q]);
6293
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!pfread(bt->name, 32, f))
6294 return qe_invalid;
6295
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 2304 times.
9216 for(size_t j = 0; j < 3; ++j)
6296 {
6297
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if (!p_getc(&(bt->counter[j]), f))
6298 return qe_invalid;
6299
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if (!p_igetw(&(bt->amount[j]), f))
6300 return qe_invalid;
6301 6912 }
6302
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bt->flags), f))
6303 return qe_invalid;
6304
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bt->next_type), f))
6305 return qe_invalid;
6306 2304 }
6307
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(size_t q = 0; q < 256; ++q)
6308 {
6309 9216 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6310
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (!pfread(bst->name, 32, f))
6311 return qe_invalid;
6312
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 9216 times.
36864 for(size_t j = 0; j < 3; ++j)
6313 {
6314
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_getc(&(bst->fill[j]), f))
6315 return qe_invalid;
6316
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->comb[j]), f))
6317 return qe_invalid;
6318
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_getc(&(bst->cset[j]), f))
6319 return qe_invalid;
6320
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->price[j]), f))
6321 return qe_invalid;
6322
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->str[j]), f))
6323 return qe_invalid;
6324 27648 }
6325 9216 }
6326 36 }
6327 else
6328 {
6329
2/2
✓ Branch 0 taken 5696 times.
✓ Branch 1 taken 89 times.
5785 for(size_t q = 0; q < 64; ++q)
6330 5696 temp_misc.bottle_types[q].clear();
6331
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 89 times.
22873 for(size_t q = 0; q < 256; ++q)
6332 22784 temp_misc.bottle_shop_types[q].clear();
6333 }
6334
6335
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 14)
6336 {
6337 byte msfx;
6338
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t q = 0; q < sfxMAX; ++q)
6339 {
6340
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&msfx,f))
6341 return qe_invalid;
6342 9216 temp_misc.miscsfx[q] = msfx;
6343 9216 }
6344 36 }
6345 else
6346 {
6347 89 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6348 89 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6349 89 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6350 }
6351
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version < 15)
6352 {
6353 89 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6354 89 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6355 89 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6356 89 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6357 89 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6358 89 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6359 89 }
6360
6361 125 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6362
6363 125 return 0;
6364 129 }
6365
6366 extern char *item_string[MAXITEMS];
6367 extern const char *old_item_string[iLast];
6368 extern char *weapon_string[MAXWPNS];
6369 extern const char *old_weapon_string[wLast];
6370
6371 129 int32_t readitems(PACKFILE *f, word version, word build)
6372 {
6373 byte padding;
6374 int32_t dummy;
6375 129 word items_to_read=MAXITEMS;
6376 itemdata tempitem;
6377 129 word s_version=0, s_cversion=0;
6378 word dummy_word;
6379
6380
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(version < 0x186)
6381 {
6382 items_to_read=64;
6383 }
6384
6385
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
6386 {
6387 125 items_to_read=0;
6388
6389 //section version info
6390
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
6391 {
6392 return qe_invalid;
6393 }
6394
6395 125 FFCore.quest_format[vItems] = s_version;
6396
6397 //al_trace("Items version %d\n", s_version);
6398
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
6399 {
6400 return qe_invalid;
6401 }
6402
6403 //section size
6404
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
6405 {
6406 return qe_invalid;
6407 }
6408
6409 //finally... section data
6410
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&items_to_read,f))
6411 {
6412 return qe_invalid;
6413 }
6414
6415
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6416 {
6417 return qe_invalid;
6418 }
6419 125 }
6420
6421
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version>1)
6422 {
6423
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<items_to_read; i++)
6424 {
6425 char tempname[64];
6426
6427
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!pfread(tempname, 64, f))
6428 {
6429 return qe_invalid;
6430 }
6431
6432 28928 item_string[i][0] = '\0';
6433 28928 strncat(item_string[i], tempname, 64 - 1);
6434 28928 }
6435 113 }
6436 else
6437 {
6438
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
6439 {
6440 4096 reset_itemname(i);
6441 4096 }
6442 }
6443
6444
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMS; i++)
6445 {
6446 33024 itemdata& id = itemsbuf[i];
6447 33024 memset(&id, 0, sizeof(itemdata));
6448 33024 id.count=-1;
6449 33024 id.playsound=WAV_SCALE;
6450 33024 reset_itembuf(&id,i);
6451 33024 }
6452
6453
2/2
✓ Branch 0 taken 30792 times.
✓ Branch 1 taken 129 times.
30921 for(int32_t i=0; i<items_to_read; i++)
6454 {
6455 30792 memset(&tempitem, 0, sizeof(itemdata));
6456 30792 reset_itembuf(&tempitem,i);
6457
6458
6459
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 21576 times.
30792 if ( s_version > 35 ) //expanded tiles
6460 {
6461
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tile,f))
6462 {
6463 return qe_invalid;
6464 }
6465 9216 }
6466 else
6467 {
6468
1/2
✓ Branch 0 taken 21576 times.
✗ Branch 1 not taken.
21576 if(!p_igetw(&tempitem.tile,f))
6469 {
6470 return qe_invalid;
6471 }
6472 }
6473
6474
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.misc_flags,f))
6475 {
6476 return qe_invalid;
6477 }
6478
6479
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.csets,f))
6480 {
6481 return qe_invalid;
6482 }
6483
6484
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.frames,f))
6485 {
6486 return qe_invalid;
6487 }
6488
6489
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.speed,f))
6490 {
6491 return qe_invalid;
6492 }
6493
6494
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.delay,f))
6495 {
6496 return qe_invalid;
6497 }
6498
6499
2/2
✓ Branch 0 taken 29768 times.
✓ Branch 1 taken 1024 times.
30792 if(version < 0x193)
6500 {
6501
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
6502 {
6503 return qe_invalid;
6504 }
6505
6506
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6507 {
6508
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6509 {
6510 case iShield:
6511 4 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6512 4 break;
6513
6514 case iMShield:
6515 4 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6516 4 break;
6517
6518 default:
6519 1016 tempitem.ltm=0;
6520 1016 break;
6521 }
6522
6523 1024 tempitem.count=-1;
6524 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6525 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6526 1024 tempitem.family=0xFF;
6527 1024 tempitem.playsound=WAV_SCALE;
6528 1024 reset_itembuf(&tempitem,i);
6529
6530 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6531
6532 1024 continue;
6533 }
6534 }
6535
6536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29768 times.
29768 if(!p_igetl(&tempitem.ltm,f))
6537 {
6538 return qe_invalid;
6539 }
6540
6541
1/2
✓ Branch 0 taken 29768 times.
✗ Branch 1 not taken.
29768 if(version < 0x193)
6542 {
6543 for(int32_t q=0; q<12; q++)
6544 {
6545 if(!p_getc(&padding,f))
6546 {
6547 return qe_invalid;
6548 }
6549 }
6550 }
6551
6552
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 840 times.
29768 if(s_version>1)
6553 {
6554
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if ( s_version >= 31 )
6555 {
6556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.family,f))
6557 {
6558 return qe_invalid;
6559 }
6560 9216 }
6561 else
6562 {
6563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.family,f))
6564 {
6565 return qe_invalid;
6566 }
6567 }
6568
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version < 16)
6569 if(tempitem.family == 0xFF)
6570 tempitem.family = itype_misc;
6571
6572
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.fam_type,f))
6573 {
6574 return qe_invalid;
6575 }
6576
6577
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version>5)
6578 {
6579
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if(s_version>=31)
6580 {
6581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.power,f))
6582 {
6583 return qe_invalid;
6584 }
6585 9216 }
6586 else
6587 {
6588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.power,f))
6589 {
6590 return qe_invalid;
6591 }
6592 }
6593
6594 //converted flags from 16b to 32b -Z
6595
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version < 41 )
6596 {
6597
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_igetw(&tempitem.flags,f))
6598 {
6599 return qe_invalid;
6600 }
6601 19712 }
6602 else
6603 {
6604
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.flags,f))
6605 {
6606 return qe_invalid;
6607 }
6608 }
6609 28928 }
6610 else
6611 {
6612 //tempitem.power = tempitem.fam_type;
6613 char tempchar;
6614
6615 if(!p_getc(&tempchar,f))
6616 {
6617 return qe_invalid;
6618 }
6619
6620 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6621 }
6622
6623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.script,f))
6624 {
6625 return qe_invalid;
6626 }
6627
6628
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<=3)
6629 {
6630 if(tempitem.script > NUMSCRIPTITEM)
6631 {
6632 tempitem.script = 0;
6633 }
6634 }
6635
6636
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.count,f))
6637 {
6638 return qe_invalid;
6639 }
6640
6641
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetw(&tempitem.amount,f))
6642 {
6643 return qe_invalid;
6644 }
6645
6646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.collect_script,f))
6647 {
6648 return qe_invalid;
6649 }
6650
6651
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<=3)
6652 {
6653 if(tempitem.collect_script > NUMSCRIPTITEM)
6654 {
6655 tempitem.collect_script = 0;
6656 }
6657 }
6658
6659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.setmax,f))
6660 {
6661 return qe_invalid;
6662 }
6663
6664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.max,f))
6665 {
6666 return qe_invalid;
6667 }
6668
6669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.playsound,f))
6670 {
6671 return qe_invalid;
6672 }
6673
6674
2/2
✓ Branch 0 taken 231424 times.
✓ Branch 1 taken 28928 times.
260352 for(int32_t j=0; j<8; j++)
6675 {
6676
1/2
✓ Branch 0 taken 231424 times.
✗ Branch 1 not taken.
231424 if(!p_igetl(&tempitem.initiald[j],f))
6677 {
6678 return qe_invalid;
6679 }
6680 231424 }
6681
6682
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 28928 times.
86784 for(int32_t j=0; j<2; j++)
6683 {
6684
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempitem.initiala[j],f))
6685 {
6686 return qe_invalid;
6687 }
6688 57856 }
6689
6690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>4)
6691 {
6692
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version>5)
6693 {
6694
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn,f))
6695 {
6696 return qe_invalid;
6697 }
6698
6699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn2,f))
6700 {
6701 return qe_invalid;
6702 }
6703
6704
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn3,f))
6705 {
6706 return qe_invalid;
6707 }
6708
6709
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn4,f))
6710 {
6711 return qe_invalid;
6712 }
6713
6714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>=15)
6715 {
6716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn5,f))
6717 {
6718 return qe_invalid;
6719 }
6720
6721
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn6,f))
6722 {
6723 return qe_invalid;
6724 }
6725
6726
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn7,f))
6727 {
6728 return qe_invalid;
6729 }
6730
6731
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn8,f))
6732 {
6733 return qe_invalid;
6734 }
6735
6736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn9,f))
6737 {
6738 return qe_invalid;
6739 }
6740
6741
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn10,f))
6742 {
6743 return qe_invalid;
6744 }
6745 28928 }
6746
6747
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.pickup_hearts,f))
6748 {
6749 return qe_invalid;
6750 }
6751
6752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version<15)
6753 {
6754 if(!p_igetw(&dummy_word,f))
6755 {
6756 return qe_invalid;
6757 }
6758
6759 tempitem.misc1=dummy_word;
6760
6761 if(!p_igetw(&dummy_word,f))
6762 {
6763 return qe_invalid;
6764 }
6765
6766 tempitem.misc2=dummy_word;
6767 }
6768 else
6769 {
6770
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc1,f))
6771 {
6772 return qe_invalid;
6773 }
6774
6775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc2,f))
6776 {
6777 return qe_invalid;
6778 }
6779
6780 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6781
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<24)
6782 {
6783 if(tempitem.family==itype_shield)
6784 {
6785 tempitem.misc1|=shSCRIPT;
6786 }
6787 }
6788 }
6789
6790
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if(s_version < 53)
6791 {
6792 byte tempbyte;
6793
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_getc(&tempbyte,f))
6794 {
6795 return qe_invalid;
6796 }
6797 19712 tempitem.cost_amount[0] = tempbyte;
6798 19712 }
6799 else
6800 {
6801
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < 2; ++q)
6802 {
6803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_igetw(&tempitem.cost_amount[q],f))
6804 {
6805 return qe_invalid;
6806 }
6807 18432 }
6808 }
6809 28928 }
6810 else
6811 {
6812 char tempchar;
6813
6814 if(!p_getc(&tempchar,f))
6815 {
6816 return qe_invalid;
6817 }
6818
6819 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6820 }
6821
6822 // June 2007: more misc. attributes
6823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>=12)
6824 {
6825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version<15)
6826 {
6827 if(!p_igetw(&dummy_word,f))
6828 {
6829 return qe_invalid;
6830 }
6831
6832 tempitem.misc3=dummy_word;
6833
6834 if(!p_igetw(&dummy_word,f))
6835 {
6836 return qe_invalid;
6837 }
6838
6839 tempitem.misc4=dummy_word;
6840 }
6841 else
6842 {
6843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc3,f))
6844 {
6845 return qe_invalid;
6846 }
6847
6848
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc4,f))
6849 {
6850 return qe_invalid;
6851 }
6852
6853
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc5,f))
6854 {
6855 return qe_invalid;
6856 }
6857
6858
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc6,f))
6859 {
6860 return qe_invalid;
6861 }
6862
6863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc7,f))
6864 {
6865 return qe_invalid;
6866 }
6867
6868
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc8,f))
6869 {
6870 return qe_invalid;
6871 }
6872
6873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc9,f))
6874 {
6875 return qe_invalid;
6876 }
6877
6878
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc10,f))
6879 {
6880 return qe_invalid;
6881 }
6882 }
6883
6884
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.usesound,f))
6885 {
6886 return qe_invalid;
6887 }
6888
6889
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if(s_version >= 49)
6890 {
6891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.usesound2,f))
6892 {
6893 return qe_invalid;
6894 }
6895 9216 }
6896 19712 else tempitem.usesound2 = 0;
6897
6898
3/4
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
✓ Branch 2 taken 19712 times.
✗ Branch 3 not taken.
28928 if(s_version < 50 && tempitem.family == itype_mirror)
6899 {
6900 //Split continue/dmap warp effect/sfx, port for old
6901 tempitem.misc2 = tempitem.misc1;
6902 tempitem.usesound2 = tempitem.usesound;
6903 }
6904 28928 }
6905 28928 }
6906
6907
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6908 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.useweapon,f))
6910 {
6911 return qe_invalid;
6912 }
6913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.usedefence,f))
6914 {
6915 return qe_invalid;
6916 }
6917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weaprange,f))
6918 {
6919 return qe_invalid;
6920 }
6921
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weapduration,f))
6922 {
6923 return qe_invalid;
6924 }
6925
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 9216 times.
101376 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6926 {
6927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92160 times.
92160 if(!p_igetl(&tempitem.weap_pattern[q],f))
6928 {
6929 return qe_invalid;
6930 }
6931 92160 }
6932 9216 }
6933
6934
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6935 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6936
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.duplicates,f))
6937 {
6938 return qe_invalid;
6939 }
6940
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
82944 for ( int32_t q = 0; q < INITIAL_D; q++ )
6941 {
6942
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 if(!p_igetl(&tempitem.weap_initiald[q],f))
6943 {
6944 return qe_invalid;
6945 }
6946 73728 }
6947
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for ( int32_t q = 0; q < INITIAL_A; q++ )
6948 {
6949
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempitem.weap_initiala[q],f))
6950 {
6951 return qe_invalid;
6952 }
6953 18432 }
6954
6955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.drawlayer,f))
6956 {
6957 return qe_invalid;
6958 }
6959
6960
6961
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hxofs,f))
6962 {
6963 return qe_invalid;
6964 }
6965
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hyofs,f))
6966 {
6967 return qe_invalid;
6968 }
6969
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hxsz,f))
6970 {
6971 return qe_invalid;
6972 }
6973
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hysz,f))
6974 {
6975 return qe_invalid;
6976 }
6977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.hzsz,f))
6978 {
6979 return qe_invalid;
6980 }
6981
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.xofs,f))
6982 {
6983 return qe_invalid;
6984 }
6985
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.yofs,f))
6986 {
6987 return qe_invalid;
6988 }
6989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hxofs,f))
6990 {
6991 return qe_invalid;
6992 }
6993
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_hyofs,f))
6994 {
6995 return qe_invalid;
6996 }
6997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hxsz,f))
6998 {
6999 return qe_invalid;
7000 }
7001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hysz,f))
7002 {
7003 return qe_invalid;
7004 }
7005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hzsz,f))
7006 {
7007 return qe_invalid;
7008 }
7009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_xofs,f))
7010 {
7011 return qe_invalid;
7012 }
7013
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_yofs,f))
7014 {
7015 return qe_invalid;
7016 }
7017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetw(&tempitem.weaponscript,f))
7018 {
7019 return qe_invalid;
7020 }
7021
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.wpnsprite,f))
7022 {
7023 return qe_invalid;
7024 }
7025 9216 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
7026
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < num_cost_tmr; ++q)
7027 {
7028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_igetl(&tempitem.magiccosttimer[q],f))
7029 {
7030 return qe_invalid;
7031 }
7032 18432 }
7033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 for(auto q = num_cost_tmr; q < 2; ++q)
7034 tempitem.magiccosttimer[q] = 0;
7035 9216 }
7036
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7037 {
7038 //Item Size FLags, TileWidth, TileHeight
7039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.overrideFLAGS,f))
7040 {
7041 return qe_invalid;
7042 }
7043
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tilew,f))
7044 {
7045 return qe_invalid;
7046 }
7047
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tileh,f))
7048 {
7049 return qe_invalid;
7050 }
7051 9216 }
7052
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 29 ) //! More new vars.
7053 {
7054 //Item Size FLags, TileWidth, TileHeight
7055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
7056 {
7057 return qe_invalid;
7058 }
7059
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_tilew,f))
7060 {
7061 return qe_invalid;
7062 }
7063
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_tileh,f))
7064 {
7065 return qe_invalid;
7066 }
7067 9216 }
7068
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 30 ) //! More new vars.
7069 {
7070 //Pickup Type
7071
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.pickup,f))
7072 {
7073 return qe_invalid;
7074 }
7075 9216 }
7076
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 32 ) //! More new vars.
7077 {
7078 //Pickup Type
7079
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempitem.pstring,f))
7080 {
7081 return qe_invalid;
7082 }
7083 9216 }
7084
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 33 ) //! More new vars.
7085 {
7086 //Pickup Type
7087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetw(&tempitem.pickup_string_flags,f))
7088 {
7089 return qe_invalid;
7090 }
7091 9216 }
7092
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 34 ) //! cost counter
7093 {
7094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(s_version < 53)
7095 {
7096 if(!p_getc(&tempitem.cost_counter[0],f))
7097 {
7098 return qe_invalid;
7099 }
7100 }
7101 else
7102 {
7103
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < 2; ++q)
7104 {
7105
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempitem.cost_counter[q],f))
7106 {
7107 return qe_invalid;
7108 }
7109 18432 }
7110 }
7111 9216 }
7112
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 44 ) //! sprite scripts
7113 {
7114
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
82944 for ( int32_t q = 0; q < 8; q++ )
7115 {
7116
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7117 {
7118
1/2
✓ Branch 0 taken 4792320 times.
✗ Branch 1 not taken.
4792320 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7119 {
7120 return qe_invalid;
7121 }
7122 4792320 }
7123
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7124 {
7125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4792320 times.
4792320 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7126 {
7127 return qe_invalid;
7128 }
7129 4792320 }
7130
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7131 {
7132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4792320 times.
4792320 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7133 {
7134 return qe_invalid;
7135 }
7136 4792320 }
7137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7138 {
7139 return qe_invalid;
7140 }
7141
7142 73728 }
7143
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for ( int32_t q = 0; q < 2; q++ )
7144 {
7145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7146 {
7147 return qe_invalid;
7148 }
7149 18432 }
7150 //Pickup Type
7151
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempitem.sprite_script,f))
7152 {
7153 return qe_invalid;
7154 }
7155 9216 }
7156
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 48 ) //! pickup flags
7157 {
7158
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&(tempitem.pickupflag),f))
7159 {
7160 return qe_invalid;
7161 }
7162 9216 }
7163
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 7936 times.
28928 if ( s_version >= 57 )
7164 {
7165 7936 std::string str;
7166
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7936 times.
✓ Branch 2 taken 7936 times.
✗ Branch 3 not taken.
7936 if(!p_getcstr(&str,f))
7167 return qe_invalid;
7168 7936 strncpy(tempitem.display_name,str.c_str(),255);
7169
1/3
✓ Branch 0 taken 7936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
7936 }
7170 28928 }
7171 else
7172 {
7173 840 tempitem.count=-1;
7174 840 tempitem.family=itype_misc;
7175 840 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7176 840 tempitem.playsound=WAV_SCALE;
7177 840 reset_itembuf(&tempitem,i);
7178 }
7179
7180 29768 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7181 29768 }
7182
7183 //////////////////////////////////////////////////////
7184 // Now do any updates because of new item additions
7185 // (These can't be done above because items_to_read
7186 // might be too low.)
7187 //////////////////////////////////////////////////////
7188
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMS; i++)
7189 {
7190 33024 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7191
7192 //Account for older quests that didn't have an actual item for the used letter
7193
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 2 && i==iLetterUsed)
7194 {
7195 16 reset_itembuf(&tempitem, iLetterUsed);
7196 16 strcpy(item_string[i],old_item_string[i]);
7197 16 tempitem.tile = itemsbuf[iLetter].tile;
7198 16 tempitem.csets = itemsbuf[iLetter].csets;
7199 16 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7200 16 tempitem.frames = itemsbuf[iLetter].frames;
7201 16 tempitem.speed = itemsbuf[iLetter].speed;
7202 16 tempitem.ltm = itemsbuf[iLetter].ltm;
7203 16 }
7204
7205
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 3)
7206 {
7207
3/3
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 3728 times.
✓ Branch 2 taken 16 times.
4096 switch(i)
7208 {
7209 case iRocsFeather:
7210 case iHoverBoots:
7211 case iSpinScroll:
7212 case iL2SpinScroll:
7213 case iCrossScroll:
7214 case iQuakeScroll:
7215 case iL2QuakeScroll:
7216 case iWhispRing:
7217 case iL2WhispRing:
7218 case iChargeRing:
7219 case iL2ChargeRing:
7220 case iPerilScroll:
7221 case iWalletL3:
7222 case iQuiverL4:
7223 case iBombBagL4:
7224 case iBracelet:
7225 case iL2Bracelet:
7226 case iOldGlove:
7227 case iL2Ladder:
7228 case iWealthMedal:
7229 case iL2WealthMedal:
7230 case iL3WealthMedal:
7231 352 reset_itembuf(&tempitem, i);
7232 352 strcpy(item_string[i],old_item_string[i]);
7233 352 break;
7234
7235 case iSShield:
7236 16 reset_itembuf(&tempitem, i);
7237 16 strcpy(item_string[i],old_item_string[i]);
7238 16 strcpy(item_string[iShield],old_item_string[iShield]);
7239 16 strcpy(item_string[iMShield],old_item_string[iMShield]);
7240 16 break;
7241 }
7242 4096 }
7243
7244
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 5)
7245 {
7246
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3984 times.
4096 switch(i)
7247 {
7248 case iHeartRing:
7249 case iL2HeartRing:
7250 case iL3HeartRing:
7251 case iMagicRing:
7252 case iL2MagicRing:
7253 case iL3MagicRing:
7254 case iL4MagicRing:
7255 112 reset_itembuf(&tempitem, i);
7256 112 strcpy(item_string[i],old_item_string[i]);
7257 112 break;
7258 }
7259 4096 }
7260
7261
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7262 {
7263
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(i!=iBPotion && i!=iRPotion)
7264 4064 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7265
7266
43/43
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
✓ Branch 16 taken 16 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 16 times.
✓ Branch 19 taken 16 times.
✓ Branch 20 taken 16 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 64 times.
✓ Branch 23 taken 3376 times.
✓ Branch 24 taken 16 times.
✓ Branch 25 taken 16 times.
✓ Branch 26 taken 16 times.
✓ Branch 27 taken 16 times.
✓ Branch 28 taken 16 times.
✓ Branch 29 taken 16 times.
✓ Branch 30 taken 16 times.
✓ Branch 31 taken 16 times.
✓ Branch 32 taken 16 times.
✓ Branch 33 taken 16 times.
✓ Branch 34 taken 16 times.
✓ Branch 35 taken 16 times.
✓ Branch 36 taken 16 times.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 16 times.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 16 times.
✓ Branch 41 taken 16 times.
✓ Branch 42 taken 16 times.
4096 switch(i)
7267 {
7268 case iTriforce:
7269 16 tempitem.fam_type=1;
7270 16 break;
7271
7272 case iBigTri:
7273 16 tempitem.fam_type=0;
7274 16 break;
7275
7276 case iBombs:
7277 16 tempitem.fam_type=i_bomb;
7278 16 tempitem.power=4;
7279 16 tempitem.wpn=wBOMB;
7280 16 tempitem.wpn2=wBOOM;
7281 16 tempitem.misc1 = 50;
7282
7283
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7284
7285 16 break;
7286
7287 case iSBomb:
7288 16 tempitem.fam_type=i_sbomb;
7289 16 tempitem.power=16;
7290 16 tempitem.wpn=wSBOMB;
7291 16 tempitem.wpn2=wSBOOM;
7292 16 tempitem.misc1 = 50;
7293
7294
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7295
7296 16 break;
7297
7298 case iBook:
7299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7300 tempitem.wpn = wFIREMAGIC;
7301
7302 16 break;
7303
7304 case iSArrow:
7305 16 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7306 16 tempitem.power=4;
7307 16 tempitem.flags|=ITEM_GAMEDATA;
7308 16 tempitem.wpn=wSARROW;
7309 16 break;
7310
7311 case iGArrow:
7312 16 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7313 16 tempitem.power=8;
7314 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7315 16 tempitem.wpn=wGARROW;
7316 16 break;
7317
7318 case iBrang:
7319 16 tempitem.power=0;
7320 16 tempitem.wpn=wBRANG;
7321 16 tempitem.misc1=36;
7322 16 break;
7323
7324 case iMBrang:
7325 16 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7326 16 tempitem.power=0;
7327 16 tempitem.wpn=wMBRANG;
7328 16 break;
7329
7330 case iFBrang:
7331 16 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7332 16 tempitem.power=2;
7333 16 tempitem.wpn=wFBRANG;
7334 16 break;
7335
7336 case iBoots:
7337 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7338 16 tempitem.power=7;
7339 16 break;
7340
7341 case iWand:
7342 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7343 16 tempitem.power=2;
7344 16 tempitem.wpn=wWAND;
7345 16 tempitem.wpn3=wMAGIC;
7346 16 break;
7347
7348 case iBCandle:
7349 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7350 16 tempitem.power=1;
7351 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7352 16 tempitem.wpn3=wFIRE;
7353 16 break;
7354
7355 case iRCandle:
7356 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7357 16 tempitem.power=1;
7358 16 tempitem.wpn3=wFIRE;
7359 16 break;
7360
7361 case iSword:
7362 16 tempitem.power=1;
7363 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7364 16 tempitem.wpn=tempitem.wpn3=wSWORD;
7365 16 tempitem.wpn2=wSWORDSLASH;
7366 16 break;
7367
7368 case iWSword:
7369 16 tempitem.power=2;
7370 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7371 16 tempitem.wpn=tempitem.wpn3=wWSWORD;
7372 16 tempitem.wpn2=wWSWORDSLASH;
7373 16 break;
7374
7375 case iMSword:
7376 16 tempitem.power=4;
7377 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7378 16 tempitem.wpn=tempitem.wpn3=wMSWORD;
7379 16 tempitem.wpn2=wMSWORDSLASH;
7380 16 break;
7381
7382 case iXSword:
7383 16 tempitem.power=8;
7384 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7385 16 tempitem.wpn=tempitem.wpn3=wXSWORD;
7386 16 tempitem.wpn2=wXSWORDSLASH;
7387 16 break;
7388
7389 case iDivineProtection:
7390 16 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7391 16 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7392 16 tempitem.wpn=wDIVINEPROTECTION1A;
7393 16 tempitem.wpn2=wDIVINEPROTECTION1B;
7394 16 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7395 16 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7396 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7397 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7398 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7399 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7400 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7401 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7402 16 tempitem.misc1=512;
7403 16 tempitem.cost_amount[0]=64;
7404 16 break;
7405
7406 case iLens:
7407 16 tempitem.misc1=60;
7408 16 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7409 16 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7410 16 break;
7411
7412 case iArrow:
7413 16 tempitem.power=2;
7414 16 tempitem.wpn=wARROW;
7415 16 break;
7416
7417 case iHoverBoots:
7418 16 tempitem.misc1=45;
7419 16 tempitem.wpn=iwHover;
7420 16 break;
7421
7422 case iDivineFire:
7423 16 tempitem.power=8;
7424 16 tempitem.wpn=wDIVINEFIRE1A;
7425 16 tempitem.wpn2=wDIVINEFIRE1B;
7426 16 tempitem.wpn3=wDIVINEFIRES1A;
7427 16 tempitem.wpn4=wDIVINEFIRES1B;
7428 16 tempitem.misc1 = 32;
7429 16 tempitem.misc2 = 200;
7430 16 tempitem.cost_amount[0]=32;
7431 16 break;
7432
7433 case iDivineEscape:
7434 16 tempitem.cost_amount[0]=32;
7435 16 break;
7436
7437 case iHookshot:
7438 16 tempitem.power=0;
7439 16 tempitem.flags&=~ITEM_FLAG1;
7440 16 tempitem.wpn=wHSHEAD;
7441 16 tempitem.wpn2=wHSCHAIN_H;
7442 16 tempitem.wpn4=wHSHANDLE;
7443 16 tempitem.wpn3=wHSCHAIN_V;
7444 16 tempitem.misc1=50;
7445 16 tempitem.misc2=100;
7446 16 break;
7447
7448 case iLongshot:
7449 16 tempitem.power=0;
7450 16 tempitem.flags&=~ITEM_FLAG1;
7451 16 tempitem.wpn=wLSHEAD;
7452 16 tempitem.wpn2=wLSCHAIN_H;
7453 16 tempitem.wpn4=wLSHANDLE;
7454 16 tempitem.wpn3=wLSCHAIN_V;
7455 16 tempitem.misc1=99;
7456 16 tempitem.misc2=100;
7457 16 break;
7458
7459 case iHammer:
7460 16 tempitem.power=4;
7461 16 tempitem.wpn=wHAMMER;
7462 16 tempitem.wpn2=iwHammerSmack;
7463 16 break;
7464
7465 case iCByrna:
7466 16 tempitem.power=1;
7467 16 tempitem.wpn=wCBYRNA;
7468 16 tempitem.wpn2=wCBYRNASLASH;
7469 16 tempitem.wpn3=wCBYRNAORB;
7470 16 tempitem.misc1=4;
7471 16 tempitem.misc2=16;
7472 16 tempitem.misc3=1;
7473 16 tempitem.cost_amount[0]=1;
7474 16 break;
7475
7476 case iWhistle:
7477 16 tempitem.wpn=wWIND;
7478 16 tempitem.misc1=3;
7479 16 tempitem.flags|=ITEM_FLAG1;
7480 16 break;
7481
7482 case iBRing:
7483 16 tempitem.power=2;
7484 16 tempitem.misc1=spBLUE;
7485 16 break;
7486
7487 case iRRing:
7488 16 tempitem.power=4;
7489 16 tempitem.misc1=spRED;
7490 16 break;
7491
7492 case iGRing:
7493 16 tempitem.power=8;
7494 16 tempitem.misc1=spGOLD;
7495 16 break;
7496
7497 case iSpinScroll:
7498 16 tempitem.power = 2;
7499 16 tempitem.misc1 = 1;
7500 16 break;
7501
7502 case iL2SpinScroll:
7503 16 tempitem.family=itype_spinscroll2;
7504 16 tempitem.fam_type=1;
7505 16 tempitem.cost_amount[0]=8;
7506 16 tempitem.power=2;
7507 16 tempitem.misc1 = 20;
7508 16 break;
7509
7510 case iQuakeScroll:
7511 16 tempitem.misc1=0x10;
7512 16 tempitem.misc2=64;
7513 16 break;
7514
7515 case iL2QuakeScroll:
7516 16 tempitem.family=itype_quakescroll2;
7517 16 tempitem.fam_type=1;
7518 16 tempitem.power = 2;
7519 16 tempitem.misc1=0x20;
7520 16 tempitem.misc2=192;
7521 16 tempitem.cost_amount[0]=8;
7522 16 break;
7523
7524 case iChargeRing:
7525 16 tempitem.misc1=64;
7526 16 tempitem.misc2=128;
7527 16 break;
7528
7529 case iL2ChargeRing:
7530 16 tempitem.misc1=32;
7531 16 tempitem.misc2=64;
7532 16 break;
7533
7534 case iOldGlove:
7535 16 tempitem.flags |= ITEM_FLAG1;
7536
7537 //fallthrough
7538 case iBombBagL4:
7539 case iWalletL3:
7540 case iQuiverL4:
7541 case iBracelet:
7542 80 tempitem.power = 1;
7543 80 break;
7544
7545 case iL2Bracelet:
7546 16 tempitem.power = 2;
7547 16 break;
7548
7549 case iMKey:
7550 16 tempitem.power=0xFF;
7551 16 tempitem.flags |= ITEM_FLAG1;
7552 16 break;
7553 }
7554 4096 }
7555
7556
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 7)
7557 {
7558
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4032 times.
4096 switch(i)
7559 {
7560 case iStoneAgony:
7561 case iStompBoots:
7562 case iPerilRing:
7563 case iWhimsicalRing:
7564 {
7565 64 reset_itembuf(&tempitem, i);
7566 64 strcpy(item_string[i],old_item_string[i]);
7567 64 break;
7568 }
7569 }
7570 4096 }
7571
7572
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 8) // May 2007: Some corrections.
7573 {
7574
7/7
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 3968 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
4096 switch(i)
7575 {
7576 case iMShield:
7577 16 tempitem.misc1|=shFLAME;
7578 16 tempitem.misc2|=shFIREBALL|shMAGIC;
7579
7580
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_qr(qr_SWORDMIRROR))
7581 {
7582 tempitem.misc2 |= shSWORD;
7583 }
7584
7585 // fallthrough
7586 case iShield:
7587 32 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7588
7589 // fallthrough
7590 case iSShield:
7591 48 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7592
7593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7594 {
7595 tempitem.misc2 |= shROCK;
7596 }
7597
7598 48 break;
7599
7600 case iWhispRing:
7601 16 tempitem.power=1;
7602 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7603 16 tempitem.misc1 = 3;
7604 16 break;
7605
7606 case iL2WhispRing:
7607 16 tempitem.power=0;
7608 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7609 16 tempitem.misc1 = 3;
7610 16 break;
7611
7612 case iL2Ladder:
7613 case iBow:
7614 case iCByrna:
7615 48 tempitem.power = 1;
7616 48 break;
7617 }
7618 4096 }
7619
7620
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 9 && i==iClock)
7621 {
7622 16 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7623 16 }
7624
7625 //add the misc flag for bomb
7626
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 10 && tempitem.family == itype_bomb)
7627 {
7628 16 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7629 16 }
7630
7631
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4064 times.
✓ Branch 3 taken 32 times.
33024 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7632 {
7633 32 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7634 32 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7635 32 }
7636
7637
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 12) // June 2007: More Misc. attributes.
7638 {
7639
5/5
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4016 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
4096 switch(i)
7640 {
7641 case iFBrang:
7642 16 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7643
7644 //fallthrough
7645 case iMBrang:
7646 32 tempitem.misc3 |= shSWORD|shMAGIC;
7647
7648 //fallthrough
7649 case iHookshot:
7650 case iLongshot:
7651 //fallthrough
7652 64 tempitem.misc3 |= shFIREBALL;
7653
7654 case iBrang:
7655 80 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7656 80 break;
7657 }
7658
7659
16/16
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1740 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 64 times.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 1956 times.
4096 switch(tempitem.family)
7660 {
7661 case itype_hoverboots:
7662 16 tempitem.usesound = WAV_ZN1HOVER;
7663 16 break;
7664
7665 case itype_wand:
7666 16 tempitem.usesound = WAV_WAND;
7667 16 break;
7668
7669 case itype_book:
7670 16 tempitem.usesound = WAV_FIRE;
7671 16 break;
7672
7673 case itype_arrow:
7674 48 tempitem.usesound = WAV_ARROW;
7675 48 break;
7676
7677 case itype_hookshot:
7678 32 tempitem.usesound = WAV_HOOKSHOT;
7679 32 break;
7680
7681 case itype_brang:
7682 48 tempitem.usesound = WAV_BRANG;
7683 48 break;
7684
7685 case itype_shield:
7686 48 tempitem.usesound = WAV_CHINK;
7687 48 break;
7688
7689 case itype_sword:
7690 1740 tempitem.usesound = WAV_SWORD;
7691 1740 break;
7692
7693 case itype_whistle:
7694 16 tempitem.usesound = WAV_WHISTLE;
7695 16 break;
7696
7697 case itype_hammer:
7698 16 tempitem.usesound = WAV_HAMMER;
7699 16 break;
7700
7701 case itype_divinefire:
7702 16 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7703 16 break;
7704
7705 case itype_divineescape:
7706 16 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7707 16 break;
7708
7709 case itype_divineprotection:
7710 16 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7711 16 break;
7712
7713 case itype_bomb:
7714 case itype_sbomb:
7715 case itype_quakescroll:
7716 case itype_quakescroll2:
7717 64 tempitem.usesound = WAV_BOMB;
7718 64 break;
7719
7720 case itype_spinscroll:
7721 case itype_spinscroll2:
7722 32 tempitem.usesound = WAV_ZN1SPINATTACK;
7723 32 break;
7724 }
7725 4096 }
7726
7727
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 13) // July 2007
7728 {
7729
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7730 {
7731 16 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7732 16 tempitem.power = 1;
7733 16 tempitem.flags|=ITEM_FLAG1;
7734 16 }
7735
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_wand)
7736 16 tempitem.flags|=ITEM_FLAG1;
7737
2/2
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 16 times.
4064 else if(tempitem.family == itype_book)
7738 {
7739 16 tempitem.flags|=ITEM_FLAG1;
7740 16 tempitem.power = 2;
7741 16 }
7742 4096 }
7743
7744
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 14) // August 2007
7745 {
7746
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
4096 if(tempitem.family == itype_fairy)
7747 {
7748 32 tempitem.usesound = WAV_SCALE;
7749
7750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tempitem.fam_type)
7751 32 tempitem.misc3=50;
7752 32 }
7753
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_potion)
7754 {
7755 32 tempitem.flags |= ITEM_GAINOLD;
7756 32 }
7757 4096 }
7758
7759
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 17) // November 2007
7760 {
7761
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
4096 if(tempitem.family == itype_candle && !tempitem.wpn3)
7762 {
7763 tempitem.wpn3 = wFIRE;
7764 }
7765
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4048 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 16 times.
4096 else if(tempitem.family == itype_arrow && tempitem.power>4)
7766 {
7767 16 tempitem.flags|=ITEM_FLAG1;
7768 16 }
7769 4096 }
7770
7771
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 18) // New Year's Eve 2007
7772 {
7773
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7774 16 tempitem.misc2 = 8; // Use the Whistle warp ring
7775
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_bait)
7776 16 tempitem.misc1 = 768; // Frames until it goes
7777
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_triforcepiece)
7778 {
7779
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 if(tempitem.flags & ITEM_GAMEDATA)
7780 {
7781 16 tempitem.misc2 = 1; // Cutscene 1
7782 16 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7783 16 }
7784 32 }
7785 4096 }
7786
7787
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 19) // January 2008
7788 {
7789
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7790 {
7791 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7792 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7793 16 }
7794 4096 }
7795
7796
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 20) // October 2008
7797 {
7798
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7799 {
7800 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7801 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7802 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7803 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7804 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7805 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7806 16 }
7807 4096 }
7808
7809
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 21) // November 2008
7810 {
7811
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(tempitem.flags & 0x0100) // ITEM_SLASH
7812 {
7813 tempitem.flags &= ~0x0100;
7814
7815 if(tempitem.family == itype_sword ||
7816 tempitem.family == itype_wand ||
7817 tempitem.family == itype_candle ||
7818 tempitem.family == itype_cbyrna)
7819 {
7820 tempitem.flags |= ITEM_FLAG4;
7821 }
7822 }
7823 4096 }
7824
7825
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 22) // September 2009
7826 {
7827
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7828 {
7829 32 tempitem.misc3 = tempitem.power/2;
7830 32 }
7831 4096 }
7832
7833
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 23) // March 2011
7834 {
7835
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_divinefire)
7836 16 tempitem.wpn5 = wFIRE;
7837
2/2
✓ Branch 0 taken 4064 times.
✓ Branch 1 taken 16 times.
4080 else if(tempitem.family == itype_book)
7838 16 tempitem.wpn2 = wFIRE;
7839 4096 }
7840
7841 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7842 // whether it was or not, and a lot of existing quests depended on the
7843 // incorrect behavior.
7844
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 25) // January 2012
7845 {
7846
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 64 times.
4096 if(tempitem.family == itype_bombbag)
7847 64 tempitem.flags |= 16;
7848
7849
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divinefire)
7850 16 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7851 4096 }
7852
7853
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7854 {
7855
60/60
✓ Branch 0 taken 7811 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 183 times.
✓ Branch 8 taken 107 times.
✓ Branch 9 taken 302 times.
✓ Branch 10 taken 276 times.
✓ Branch 11 taken 183 times.
✓ Branch 12 taken 283 times.
✓ Branch 13 taken 184 times.
✓ Branch 14 taken 92 times.
✓ Branch 15 taken 184 times.
✓ Branch 16 taken 107 times.
✓ Branch 17 taken 92 times.
✓ Branch 18 taken 279 times.
✓ Branch 19 taken 93 times.
✓ Branch 20 taken 94 times.
✓ Branch 21 taken 184 times.
✓ Branch 22 taken 92 times.
✓ Branch 23 taken 93 times.
✓ Branch 24 taken 92 times.
✓ Branch 25 taken 92 times.
✓ Branch 26 taken 92 times.
✓ Branch 27 taken 107 times.
✓ Branch 28 taken 92 times.
✓ Branch 29 taken 93 times.
✓ Branch 30 taken 92 times.
✓ Branch 31 taken 93 times.
✓ Branch 32 taken 184 times.
✓ Branch 33 taken 368 times.
✓ Branch 34 taken 94 times.
✓ Branch 35 taken 92 times.
✓ Branch 36 taken 168 times.
✓ Branch 37 taken 368 times.
✓ Branch 38 taken 92 times.
✓ Branch 39 taken 92 times.
✓ Branch 40 taken 92 times.
✓ Branch 41 taken 92 times.
✓ Branch 42 taken 92 times.
✓ Branch 43 taken 185 times.
✓ Branch 44 taken 184 times.
✓ Branch 45 taken 92 times.
✓ Branch 46 taken 277 times.
✓ Branch 47 taken 278 times.
✓ Branch 48 taken 372 times.
✓ Branch 49 taken 92 times.
✓ Branch 50 taken 92 times.
✓ Branch 51 taken 92 times.
✓ Branch 52 taken 92 times.
✓ Branch 53 taken 92 times.
✓ Branch 54 taken 93 times.
✓ Branch 55 taken 2541 times.
✓ Branch 56 taken 983 times.
✓ Branch 57 taken 277 times.
✓ Branch 58 taken 1135 times.
✓ Branch 59 taken 2617 times.
23808 switch(tempitem.family)
7856 {
7857 case itype_sword:
7858 {
7859 7811 tempitem.flags &= ~(ITEM_FLAG5);
7860 7811 tempitem.misc3 = 0;
7861 7811 tempitem.misc4 = 0;
7862 7811 tempitem.misc5 = 0;
7863 7811 tempitem.misc6 = 0;
7864 7811 tempitem.misc7 = 0;
7865 7811 tempitem.misc8 = 0;
7866 7811 tempitem.misc9 = 0;
7867 7811 tempitem.misc10 = 0;
7868 7811 tempitem.wpn4 = 0;
7869 7811 tempitem.wpn5 = 0;
7870 7811 tempitem.wpn6 = 0;
7871 7811 tempitem.wpn7 = 0;
7872 7811 tempitem.wpn8 = 0;
7873 7811 tempitem.wpn9 = 0;
7874 7811 tempitem.wpn10 = 0;
7875 7811 break;
7876 }
7877 case itype_brang:
7878 {
7879 277 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7880 277 tempitem.misc2 = 0;
7881 277 tempitem.misc5 = 0;
7882 277 tempitem.misc6 = 0;
7883 277 tempitem.misc7 = 0;
7884 277 tempitem.misc8 = 0;
7885 277 tempitem.misc9 = 0;
7886 277 tempitem.misc10 = 0;
7887 277 tempitem.wpn4 = 0;
7888 277 tempitem.wpn5 = 0;
7889 277 tempitem.wpn6 = 0;
7890 277 tempitem.wpn7 = 0;
7891 277 tempitem.wpn8 = 0;
7892 277 tempitem.wpn9 = 0;
7893 277 tempitem.wpn10 = 0;
7894 277 break;
7895 }
7896 case itype_arrow:
7897 {
7898 274 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7899 274 tempitem.misc2 = 0;
7900 274 tempitem.misc3 = 0;
7901 274 tempitem.misc4 = 0;
7902 274 tempitem.misc5 = 0;
7903 274 tempitem.misc6 = 0;
7904 274 tempitem.misc7 = 0;
7905 274 tempitem.misc8 = 0;
7906 274 tempitem.misc9 = 0;
7907 274 tempitem.misc10 = 0;
7908 274 tempitem.wpn4 = 0;
7909 274 tempitem.wpn5 = 0;
7910 274 tempitem.wpn6 = 0;
7911 274 tempitem.wpn7 = 0;
7912 274 tempitem.wpn8 = 0;
7913 274 tempitem.wpn9 = 0;
7914 274 tempitem.wpn10 = 0;
7915 274 break;
7916 }
7917 case itype_candle:
7918 {
7919 222 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7920 222 tempitem.misc1 = 0;
7921 222 tempitem.misc2 = 0;
7922 222 tempitem.misc3 = 0;
7923 222 tempitem.misc4 = 0;
7924 222 tempitem.misc5 = 0;
7925 222 tempitem.misc6 = 0;
7926 222 tempitem.misc7 = 0;
7927 222 tempitem.misc8 = 0;
7928 222 tempitem.misc9 = 0;
7929 222 tempitem.misc10 = 0;
7930 222 tempitem.wpn4 = 0;
7931 222 tempitem.wpn5 = 0;
7932 222 tempitem.wpn6 = 0;
7933 222 tempitem.wpn7 = 0;
7934 222 tempitem.wpn8 = 0;
7935 222 tempitem.wpn9 = 0;
7936 222 tempitem.wpn10 = 0;
7937 222 break;
7938 }
7939 case itype_whistle:
7940 {
7941 138 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7942 138 tempitem.misc3 = 0;
7943 138 tempitem.misc4 = 0;
7944 138 tempitem.misc5 = 0;
7945 138 tempitem.misc6 = 0;
7946 138 tempitem.misc7 = 0;
7947 138 tempitem.misc8 = 0;
7948 138 tempitem.misc9 = 0;
7949 138 tempitem.misc10 = 0;
7950 138 tempitem.wpn2 = 0;
7951 138 tempitem.wpn3 = 0;
7952 138 tempitem.wpn4 = 0;
7953 138 tempitem.wpn5 = 0;
7954 138 tempitem.wpn6 = 0;
7955 138 tempitem.wpn7 = 0;
7956 138 tempitem.wpn8 = 0;
7957 138 tempitem.wpn9 = 0;
7958 138 tempitem.wpn10 = 0;
7959 138 break;
7960 }
7961 case itype_bait:
7962 {
7963 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7964 93 tempitem.misc2 = 0;
7965 93 tempitem.misc3 = 0;
7966 93 tempitem.misc4 = 0;
7967 93 tempitem.misc5 = 0;
7968 93 tempitem.misc6 = 0;
7969 93 tempitem.misc7 = 0;
7970 93 tempitem.misc8 = 0;
7971 93 tempitem.misc9 = 0;
7972 93 tempitem.misc10 = 0;
7973 93 tempitem.wpn2 = 0;
7974 93 tempitem.wpn3 = 0;
7975 93 tempitem.wpn4 = 0;
7976 93 tempitem.wpn5 = 0;
7977 93 tempitem.wpn6 = 0;
7978 93 tempitem.wpn7 = 0;
7979 93 tempitem.wpn8 = 0;
7980 93 tempitem.wpn9 = 0;
7981 93 tempitem.wpn10 = 0;
7982 93 break;
7983 }
7984 case itype_letter:
7985 {
7986 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7987 184 tempitem.misc1 = 0;
7988 184 tempitem.misc2 = 0;
7989 184 tempitem.misc3 = 0;
7990 184 tempitem.misc4 = 0;
7991 184 tempitem.misc5 = 0;
7992 184 tempitem.misc6 = 0;
7993 184 tempitem.misc7 = 0;
7994 184 tempitem.misc8 = 0;
7995 184 tempitem.misc9 = 0;
7996 184 tempitem.misc10 = 0;
7997 184 tempitem.wpn = 0;
7998 184 tempitem.wpn2 = 0;
7999 184 tempitem.wpn3 = 0;
8000 184 tempitem.wpn4 = 0;
8001 184 tempitem.wpn5 = 0;
8002 184 tempitem.wpn6 = 0;
8003 184 tempitem.wpn7 = 0;
8004 184 tempitem.wpn8 = 0;
8005 184 tempitem.wpn9 = 0;
8006 184 tempitem.wpn10 = 0;
8007 184 break;
8008 }
8009 case itype_potion:
8010 {
8011 183 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8012 183 tempitem.misc3 = 0;
8013 183 tempitem.misc4 = 0;
8014 183 tempitem.misc5 = 0;
8015 183 tempitem.misc6 = 0;
8016 183 tempitem.misc7 = 0;
8017 183 tempitem.misc8 = 0;
8018 183 tempitem.misc9 = 0;
8019 183 tempitem.misc10 = 0;
8020 183 tempitem.wpn = 0;
8021 183 tempitem.wpn2 = 0;
8022 183 tempitem.wpn3 = 0;
8023 183 tempitem.wpn4 = 0;
8024 183 tempitem.wpn5 = 0;
8025 183 tempitem.wpn6 = 0;
8026 183 tempitem.wpn7 = 0;
8027 183 tempitem.wpn8 = 0;
8028 183 tempitem.wpn9 = 0;
8029 183 tempitem.wpn10 = 0;
8030 183 break;
8031 }
8032 case itype_wand:
8033 {
8034 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8035 107 tempitem.misc1 = 0;
8036 107 tempitem.misc2 = 0;
8037 107 tempitem.misc3 = 0;
8038 107 tempitem.misc4 = 0;
8039 107 tempitem.misc5 = 0;
8040 107 tempitem.misc6 = 0;
8041 107 tempitem.misc7 = 0;
8042 107 tempitem.misc8 = 0;
8043 107 tempitem.misc9 = 0;
8044 107 tempitem.misc10 = 0;
8045 107 tempitem.wpn4 = 0;
8046 107 tempitem.wpn5 = 0;
8047 107 tempitem.wpn6 = 0;
8048 107 tempitem.wpn7 = 0;
8049 107 tempitem.wpn8 = 0;
8050 107 tempitem.wpn9 = 0;
8051 107 tempitem.wpn10 = 0;
8052 107 break;
8053 }
8054 case itype_ring:
8055 {
8056 302 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8057 302 tempitem.misc2 = 0;
8058 302 tempitem.misc3 = 0;
8059 302 tempitem.misc4 = 0;
8060 302 tempitem.misc5 = 0;
8061 302 tempitem.misc6 = 0;
8062 302 tempitem.misc7 = 0;
8063 302 tempitem.misc8 = 0;
8064 302 tempitem.misc9 = 0;
8065 302 tempitem.misc10 = 0;
8066 302 tempitem.wpn = 0;
8067 302 tempitem.wpn2 = 0;
8068 302 tempitem.wpn3 = 0;
8069 302 tempitem.wpn4 = 0;
8070 302 tempitem.wpn5 = 0;
8071 302 tempitem.wpn6 = 0;
8072 302 tempitem.wpn7 = 0;
8073 302 tempitem.wpn8 = 0;
8074 302 tempitem.wpn9 = 0;
8075 302 tempitem.wpn10 = 0;
8076 302 break;
8077 }
8078 case itype_wallet:
8079 {
8080 276 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8081 276 tempitem.misc3 = 0;
8082 276 tempitem.misc4 = 0;
8083 276 tempitem.misc5 = 0;
8084 276 tempitem.misc6 = 0;
8085 276 tempitem.misc7 = 0;
8086 276 tempitem.misc8 = 0;
8087 276 tempitem.misc9 = 0;
8088 276 tempitem.misc10 = 0;
8089 276 tempitem.wpn = 0;
8090 276 tempitem.wpn2 = 0;
8091 276 tempitem.wpn3 = 0;
8092 276 tempitem.wpn4 = 0;
8093 276 tempitem.wpn5 = 0;
8094 276 tempitem.wpn6 = 0;
8095 276 tempitem.wpn7 = 0;
8096 276 tempitem.wpn8 = 0;
8097 276 tempitem.wpn9 = 0;
8098 276 tempitem.wpn10 = 0;
8099 276 break;
8100 }
8101 case itype_amulet:
8102 {
8103 183 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8104 183 tempitem.misc1 = 0;
8105 183 tempitem.misc2 = 0;
8106 183 tempitem.misc3 = 0;
8107 183 tempitem.misc4 = 0;
8108 183 tempitem.misc5 = 0;
8109 183 tempitem.misc6 = 0;
8110 183 tempitem.misc7 = 0;
8111 183 tempitem.misc8 = 0;
8112 183 tempitem.misc9 = 0;
8113 183 tempitem.misc10 = 0;
8114 183 tempitem.wpn = 0;
8115 183 tempitem.wpn2 = 0;
8116 183 tempitem.wpn3 = 0;
8117 183 tempitem.wpn4 = 0;
8118 183 tempitem.wpn5 = 0;
8119 183 tempitem.wpn6 = 0;
8120 183 tempitem.wpn7 = 0;
8121 183 tempitem.wpn8 = 0;
8122 183 tempitem.wpn9 = 0;
8123 183 tempitem.wpn10 = 0;
8124 183 break;
8125 }
8126 case itype_shield:
8127 {
8128 283 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8129 283 tempitem.misc3 = 0;
8130 283 tempitem.misc4 = 0;
8131 283 tempitem.misc5 = 0;
8132 283 tempitem.misc6 = 0;
8133 283 tempitem.misc7 = 0;
8134 283 tempitem.misc8 = 0;
8135 283 tempitem.misc9 = 0;
8136 283 tempitem.misc10 = 0;
8137 283 tempitem.wpn = 0;
8138 283 tempitem.wpn2 = 0;
8139 283 tempitem.wpn3 = 0;
8140 283 tempitem.wpn4 = 0;
8141 283 tempitem.wpn5 = 0;
8142 283 tempitem.wpn6 = 0;
8143 283 tempitem.wpn7 = 0;
8144 283 tempitem.wpn8 = 0;
8145 283 tempitem.wpn9 = 0;
8146 283 tempitem.wpn10 = 0;
8147 283 break;
8148 }
8149 case itype_bow:
8150 {
8151 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8152 184 tempitem.misc1 = 0;
8153 184 tempitem.misc2 = 0;
8154 184 tempitem.misc3 = 0;
8155 184 tempitem.misc4 = 0;
8156 184 tempitem.misc5 = 0;
8157 184 tempitem.misc6 = 0;
8158 184 tempitem.misc7 = 0;
8159 184 tempitem.misc8 = 0;
8160 184 tempitem.misc9 = 0;
8161 184 tempitem.misc10 = 0;
8162 184 tempitem.wpn = 0;
8163 184 tempitem.wpn2 = 0;
8164 184 tempitem.wpn3 = 0;
8165 184 tempitem.wpn4 = 0;
8166 184 tempitem.wpn5 = 0;
8167 184 tempitem.wpn6 = 0;
8168 184 tempitem.wpn7 = 0;
8169 184 tempitem.wpn8 = 0;
8170 184 tempitem.wpn9 = 0;
8171 184 tempitem.wpn10 = 0;
8172 184 break;
8173 }
8174 case itype_raft:
8175 {
8176 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8177 92 tempitem.misc1 = 0;
8178 92 tempitem.misc2 = 0;
8179 92 tempitem.misc3 = 0;
8180 92 tempitem.misc4 = 0;
8181 92 tempitem.misc5 = 0;
8182 92 tempitem.misc6 = 0;
8183 92 tempitem.misc7 = 0;
8184 92 tempitem.misc8 = 0;
8185 92 tempitem.misc9 = 0;
8186 92 tempitem.misc10 = 0;
8187 92 tempitem.wpn = 0;
8188 92 tempitem.wpn2 = 0;
8189 92 tempitem.wpn3 = 0;
8190 92 tempitem.wpn4 = 0;
8191 92 tempitem.wpn5 = 0;
8192 92 tempitem.wpn6 = 0;
8193 92 tempitem.wpn7 = 0;
8194 92 tempitem.wpn8 = 0;
8195 92 tempitem.wpn9 = 0;
8196 92 tempitem.wpn10 = 0;
8197 92 break;
8198 }
8199 case itype_ladder:
8200 {
8201 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8202 184 tempitem.misc1 = 0;
8203 184 tempitem.misc2 = 0;
8204 184 tempitem.misc3 = 0;
8205 184 tempitem.misc4 = 0;
8206 184 tempitem.misc5 = 0;
8207 184 tempitem.misc6 = 0;
8208 184 tempitem.misc7 = 0;
8209 184 tempitem.misc8 = 0;
8210 184 tempitem.misc9 = 0;
8211 184 tempitem.misc10 = 0;
8212 184 tempitem.wpn = 0;
8213 184 tempitem.wpn2 = 0;
8214 184 tempitem.wpn3 = 0;
8215 184 tempitem.wpn4 = 0;
8216 184 tempitem.wpn5 = 0;
8217 184 tempitem.wpn6 = 0;
8218 184 tempitem.wpn7 = 0;
8219 184 tempitem.wpn8 = 0;
8220 184 tempitem.wpn9 = 0;
8221 184 tempitem.wpn10 = 0;
8222 184 break;
8223 }
8224 case itype_book:
8225 {
8226 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8227 107 tempitem.misc1 = 0;
8228 107 tempitem.misc2 = 0;
8229 107 tempitem.misc3 = 0;
8230 107 tempitem.misc4 = 0;
8231 107 tempitem.misc5 = 0;
8232 107 tempitem.misc6 = 0;
8233 107 tempitem.misc7 = 0;
8234 107 tempitem.misc8 = 0;
8235 107 tempitem.misc9 = 0;
8236 107 tempitem.misc10 = 0;
8237 107 tempitem.wpn3 = 0;
8238 107 tempitem.wpn4 = 0;
8239 107 tempitem.wpn5 = 0;
8240 107 tempitem.wpn6 = 0;
8241 107 tempitem.wpn7 = 0;
8242 107 tempitem.wpn8 = 0;
8243 107 tempitem.wpn9 = 0;
8244 107 tempitem.wpn10 = 0;
8245 107 break;
8246 }
8247 case itype_magickey:
8248 {
8249 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8250 92 tempitem.misc1 = 0;
8251 92 tempitem.misc2 = 0;
8252 92 tempitem.misc3 = 0;
8253 92 tempitem.misc4 = 0;
8254 92 tempitem.misc5 = 0;
8255 92 tempitem.misc6 = 0;
8256 92 tempitem.misc7 = 0;
8257 92 tempitem.misc8 = 0;
8258 92 tempitem.misc9 = 0;
8259 92 tempitem.misc10 = 0;
8260 92 tempitem.wpn = 0;
8261 92 tempitem.wpn2 = 0;
8262 92 tempitem.wpn3 = 0;
8263 92 tempitem.wpn4 = 0;
8264 92 tempitem.wpn5 = 0;
8265 92 tempitem.wpn6 = 0;
8266 92 tempitem.wpn7 = 0;
8267 92 tempitem.wpn8 = 0;
8268 92 tempitem.wpn9 = 0;
8269 92 tempitem.wpn10 = 0;
8270 92 break;
8271 }
8272 case itype_bracelet:
8273 {
8274 279 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8275 279 tempitem.misc1 = 0;
8276 279 tempitem.misc2 = 0;
8277 279 tempitem.misc3 = 0;
8278 279 tempitem.misc4 = 0;
8279 279 tempitem.misc5 = 0;
8280 279 tempitem.misc6 = 0;
8281 279 tempitem.misc7 = 0;
8282 279 tempitem.misc8 = 0;
8283 279 tempitem.misc9 = 0;
8284 279 tempitem.misc10 = 0;
8285 279 tempitem.wpn = 0;
8286 279 tempitem.wpn2 = 0;
8287 279 tempitem.wpn3 = 0;
8288 279 tempitem.wpn4 = 0;
8289 279 tempitem.wpn5 = 0;
8290 279 tempitem.wpn6 = 0;
8291 279 tempitem.wpn7 = 0;
8292 279 tempitem.wpn8 = 0;
8293 279 tempitem.wpn9 = 0;
8294 279 tempitem.wpn10 = 0;
8295 279 break;
8296 }
8297 case itype_flippers:
8298 {
8299 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8300 93 tempitem.misc1 = 0;
8301 93 tempitem.misc2 = 0;
8302 93 tempitem.misc3 = 0;
8303 93 tempitem.misc4 = 0;
8304 93 tempitem.misc5 = 0;
8305 93 tempitem.misc6 = 0;
8306 93 tempitem.misc7 = 0;
8307 93 tempitem.misc8 = 0;
8308 93 tempitem.misc9 = 0;
8309 93 tempitem.misc10 = 0;
8310 93 tempitem.wpn = 0;
8311 93 tempitem.wpn2 = 0;
8312 93 tempitem.wpn3 = 0;
8313 93 tempitem.wpn4 = 0;
8314 93 tempitem.wpn5 = 0;
8315 93 tempitem.wpn6 = 0;
8316 93 tempitem.wpn7 = 0;
8317 93 tempitem.wpn8 = 0;
8318 93 tempitem.wpn9 = 0;
8319 93 tempitem.wpn10 = 0;
8320 93 break;
8321 }
8322 case itype_boots:
8323 {
8324 94 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8325 94 tempitem.misc1 = 0;
8326 94 tempitem.misc2 = 0;
8327 94 tempitem.misc3 = 0;
8328 94 tempitem.misc4 = 0;
8329 94 tempitem.misc5 = 0;
8330 94 tempitem.misc6 = 0;
8331 94 tempitem.misc7 = 0;
8332 94 tempitem.misc8 = 0;
8333 94 tempitem.misc9 = 0;
8334 94 tempitem.misc10 = 0;
8335 94 tempitem.wpn = 0;
8336 94 tempitem.wpn2 = 0;
8337 94 tempitem.wpn3 = 0;
8338 94 tempitem.wpn4 = 0;
8339 94 tempitem.wpn5 = 0;
8340 94 tempitem.wpn6 = 0;
8341 94 tempitem.wpn7 = 0;
8342 94 tempitem.wpn8 = 0;
8343 94 tempitem.wpn9 = 0;
8344 94 tempitem.wpn10 = 0;
8345 94 break;
8346 }
8347 case itype_hookshot:
8348 {
8349 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8350 184 tempitem.misc5 = 0;
8351 184 tempitem.misc6 = 0;
8352 184 tempitem.misc7 = 0;
8353 184 tempitem.misc8 = 0;
8354 184 tempitem.misc9 = 0;
8355 184 tempitem.misc10 = 0;
8356 184 tempitem.wpn5 = 0;
8357 184 tempitem.wpn6 = 0;
8358 184 tempitem.wpn7 = 0;
8359 184 tempitem.wpn8 = 0;
8360 184 tempitem.wpn9 = 0;
8361 184 tempitem.wpn10 = 0;
8362 184 break;
8363 }
8364 case itype_lens:
8365 {
8366 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8367 92 tempitem.misc2 = 0;
8368 92 tempitem.misc3 = 0;
8369 92 tempitem.misc4 = 0;
8370 92 tempitem.misc5 = 0;
8371 92 tempitem.misc6 = 0;
8372 92 tempitem.misc7 = 0;
8373 92 tempitem.misc8 = 0;
8374 92 tempitem.misc9 = 0;
8375 92 tempitem.misc10 = 0;
8376 92 tempitem.wpn = 0;
8377 92 tempitem.wpn2 = 0;
8378 92 tempitem.wpn3 = 0;
8379 92 tempitem.wpn4 = 0;
8380 92 tempitem.wpn5 = 0;
8381 92 tempitem.wpn6 = 0;
8382 92 tempitem.wpn7 = 0;
8383 92 tempitem.wpn8 = 0;
8384 92 tempitem.wpn9 = 0;
8385 92 tempitem.wpn10 = 0;
8386 92 break;
8387 }
8388 case itype_hammer:
8389 {
8390 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8391 93 tempitem.misc1 = 0;
8392 93 tempitem.misc2 = 0;
8393 93 tempitem.misc3 = 0;
8394 93 tempitem.misc4 = 0;
8395 93 tempitem.misc5 = 0;
8396 93 tempitem.misc6 = 0;
8397 93 tempitem.misc7 = 0;
8398 93 tempitem.misc8 = 0;
8399 93 tempitem.misc9 = 0;
8400 93 tempitem.misc10 = 0;
8401 93 tempitem.wpn3 = 0;
8402 93 tempitem.wpn4 = 0;
8403 93 tempitem.wpn5 = 0;
8404 93 tempitem.wpn6 = 0;
8405 93 tempitem.wpn7 = 0;
8406 93 tempitem.wpn8 = 0;
8407 93 tempitem.wpn9 = 0;
8408 93 tempitem.wpn10 = 0;
8409 93 break;
8410 }
8411 case itype_divinefire:
8412 {
8413 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8414 92 tempitem.misc3 = 0;
8415 92 tempitem.misc4 = 0;
8416 92 tempitem.misc5 = 0;
8417 92 tempitem.misc6 = 0;
8418 92 tempitem.misc7 = 0;
8419 92 tempitem.misc8 = 0;
8420 92 tempitem.misc9 = 0;
8421 92 tempitem.misc10 = 0;
8422 92 tempitem.wpn6 = 0;
8423 92 tempitem.wpn7 = 0;
8424 92 tempitem.wpn8 = 0;
8425 92 tempitem.wpn9 = 0;
8426 92 tempitem.wpn10 = 0;
8427 92 break;
8428 }
8429 case itype_divineescape:
8430 {
8431 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8432 92 tempitem.misc2 = 0;
8433 92 tempitem.misc3 = 0;
8434 92 tempitem.misc4 = 0;
8435 92 tempitem.misc5 = 0;
8436 92 tempitem.misc6 = 0;
8437 92 tempitem.misc7 = 0;
8438 92 tempitem.misc8 = 0;
8439 92 tempitem.misc9 = 0;
8440 92 tempitem.misc10 = 0;
8441 92 tempitem.wpn = 0;
8442 92 tempitem.wpn2 = 0;
8443 92 tempitem.wpn3 = 0;
8444 92 tempitem.wpn4 = 0;
8445 92 tempitem.wpn5 = 0;
8446 92 tempitem.wpn6 = 0;
8447 92 tempitem.wpn7 = 0;
8448 92 tempitem.wpn8 = 0;
8449 92 tempitem.wpn9 = 0;
8450 92 tempitem.wpn10 = 0;
8451 92 break;
8452 }
8453 case itype_divineprotection:
8454 {
8455 92 tempitem.flags &= ~ (ITEM_FLAG5);
8456 92 tempitem.misc2 = 0;
8457 92 tempitem.misc3 = 0;
8458 92 tempitem.misc4 = 0;
8459 92 tempitem.misc5 = 0;
8460 92 tempitem.misc6 = 0;
8461 92 tempitem.misc7 = 0;
8462 92 tempitem.misc8 = 0;
8463 92 tempitem.misc9 = 0;
8464 92 tempitem.misc10 = 0;
8465 92 break;
8466 }
8467 case itype_bomb:
8468 {
8469 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8470 107 tempitem.misc4 = 0;
8471 107 tempitem.misc5 = 0;
8472 107 tempitem.misc6 = 0;
8473 107 tempitem.misc7 = 0;
8474 107 tempitem.misc8 = 0;
8475 107 tempitem.misc9 = 0;
8476 107 tempitem.misc10 = 0;
8477 107 tempitem.wpn3 = 0;
8478 107 tempitem.wpn4 = 0;
8479 107 tempitem.wpn5 = 0;
8480 107 tempitem.wpn6 = 0;
8481 107 tempitem.wpn7 = 0;
8482 107 tempitem.wpn8 = 0;
8483 107 tempitem.wpn9 = 0;
8484 107 tempitem.wpn10 = 0;
8485 107 break;
8486 }
8487 case itype_sbomb:
8488 {
8489 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8490 92 tempitem.misc4 = 0;
8491 92 tempitem.misc5 = 0;
8492 92 tempitem.misc6 = 0;
8493 92 tempitem.misc7 = 0;
8494 92 tempitem.misc8 = 0;
8495 92 tempitem.misc9 = 0;
8496 92 tempitem.misc10 = 0;
8497 92 tempitem.wpn3 = 0;
8498 92 tempitem.wpn4 = 0;
8499 92 tempitem.wpn5 = 0;
8500 92 tempitem.wpn6 = 0;
8501 92 tempitem.wpn7 = 0;
8502 92 tempitem.wpn8 = 0;
8503 92 tempitem.wpn9 = 0;
8504 92 tempitem.wpn10 = 0;
8505 92 break;
8506 }
8507 case itype_clock:
8508 {
8509 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8510 93 tempitem.misc2 = 0;
8511 93 tempitem.misc3 = 0;
8512 93 tempitem.misc4 = 0;
8513 93 tempitem.misc5 = 0;
8514 93 tempitem.misc6 = 0;
8515 93 tempitem.misc7 = 0;
8516 93 tempitem.misc8 = 0;
8517 93 tempitem.misc9 = 0;
8518 93 tempitem.misc10 = 0;
8519 93 tempitem.wpn = 0;
8520 93 tempitem.wpn2 = 0;
8521 93 tempitem.wpn3 = 0;
8522 93 tempitem.wpn4 = 0;
8523 93 tempitem.wpn5 = 0;
8524 93 tempitem.wpn6 = 0;
8525 93 tempitem.wpn7 = 0;
8526 93 tempitem.wpn8 = 0;
8527 93 tempitem.wpn9 = 0;
8528 93 tempitem.wpn10 = 0;
8529 93 break;
8530 }
8531 case itype_key:
8532 {
8533 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8534 92 tempitem.misc1 = 0;
8535 92 tempitem.misc2 = 0;
8536 92 tempitem.misc3 = 0;
8537 92 tempitem.misc4 = 0;
8538 92 tempitem.misc5 = 0;
8539 92 tempitem.misc6 = 0;
8540 92 tempitem.misc7 = 0;
8541 92 tempitem.misc8 = 0;
8542 92 tempitem.misc9 = 0;
8543 92 tempitem.misc10 = 0;
8544 92 tempitem.wpn = 0;
8545 92 tempitem.wpn2 = 0;
8546 92 tempitem.wpn3 = 0;
8547 92 tempitem.wpn4 = 0;
8548 92 tempitem.wpn5 = 0;
8549 92 tempitem.wpn6 = 0;
8550 92 tempitem.wpn7 = 0;
8551 92 tempitem.wpn8 = 0;
8552 92 tempitem.wpn9 = 0;
8553 92 tempitem.wpn10 = 0;
8554 92 break;
8555 }
8556 case itype_magiccontainer:
8557 {
8558 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8559 93 tempitem.misc1 = 0;
8560 93 tempitem.misc2 = 0;
8561 93 tempitem.misc3 = 0;
8562 93 tempitem.misc4 = 0;
8563 93 tempitem.misc5 = 0;
8564 93 tempitem.misc6 = 0;
8565 93 tempitem.misc7 = 0;
8566 93 tempitem.misc8 = 0;
8567 93 tempitem.misc9 = 0;
8568 93 tempitem.misc10 = 0;
8569 93 tempitem.wpn = 0;
8570 93 tempitem.wpn2 = 0;
8571 93 tempitem.wpn3 = 0;
8572 93 tempitem.wpn4 = 0;
8573 93 tempitem.wpn5 = 0;
8574 93 tempitem.wpn6 = 0;
8575 93 tempitem.wpn7 = 0;
8576 93 tempitem.wpn8 = 0;
8577 93 tempitem.wpn9 = 0;
8578 93 tempitem.wpn10 = 0;
8579 93 break;
8580 }
8581 case itype_triforcepiece:
8582 {
8583 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8584 184 tempitem.misc3 = 0;
8585 184 tempitem.misc4 = 0;
8586 184 tempitem.misc5 = 0;
8587 184 tempitem.misc6 = 0;
8588 184 tempitem.misc7 = 0;
8589 184 tempitem.misc8 = 0;
8590 184 tempitem.misc9 = 0;
8591 184 tempitem.misc10 = 0;
8592 184 tempitem.wpn = 0;
8593 184 tempitem.wpn2 = 0;
8594 184 tempitem.wpn3 = 0;
8595 184 tempitem.wpn4 = 0;
8596 184 tempitem.wpn5 = 0;
8597 184 tempitem.wpn6 = 0;
8598 184 tempitem.wpn7 = 0;
8599 184 tempitem.wpn8 = 0;
8600 184 tempitem.wpn9 = 0;
8601 184 tempitem.wpn10 = 0;
8602 184 break;
8603 }
8604 case itype_map: case itype_compass: case itype_bosskey:
8605 {
8606 277 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8607 277 tempitem.misc1 = 0;
8608 277 tempitem.misc2 = 0;
8609 277 tempitem.misc3 = 0;
8610 277 tempitem.misc4 = 0;
8611 277 tempitem.misc5 = 0;
8612 277 tempitem.misc6 = 0;
8613 277 tempitem.misc7 = 0;
8614 277 tempitem.misc8 = 0;
8615 277 tempitem.misc9 = 0;
8616 277 tempitem.misc10 = 0;
8617 277 tempitem.wpn = 0;
8618 277 tempitem.wpn2 = 0;
8619 277 tempitem.wpn3 = 0;
8620 277 tempitem.wpn4 = 0;
8621 277 tempitem.wpn5 = 0;
8622 277 tempitem.wpn6 = 0;
8623 277 tempitem.wpn7 = 0;
8624 277 tempitem.wpn8 = 0;
8625 277 tempitem.wpn9 = 0;
8626 277 tempitem.wpn10 = 0;
8627 277 break;
8628 }
8629 case itype_quiver:
8630 {
8631 368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8632 368 tempitem.misc3 = 0;
8633 368 tempitem.misc4 = 0;
8634 368 tempitem.misc5 = 0;
8635 368 tempitem.misc6 = 0;
8636 368 tempitem.misc7 = 0;
8637 368 tempitem.misc8 = 0;
8638 368 tempitem.misc9 = 0;
8639 368 tempitem.misc10 = 0;
8640 368 tempitem.wpn = 0;
8641 368 tempitem.wpn2 = 0;
8642 368 tempitem.wpn3 = 0;
8643 368 tempitem.wpn4 = 0;
8644 368 tempitem.wpn5 = 0;
8645 368 tempitem.wpn6 = 0;
8646 368 tempitem.wpn7 = 0;
8647 368 tempitem.wpn8 = 0;
8648 368 tempitem.wpn9 = 0;
8649 368 tempitem.wpn10 = 0;
8650 368 break;
8651 }
8652 case itype_lkey:
8653 {
8654 94 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8655 94 tempitem.misc1 = 0;
8656 94 tempitem.misc2 = 0;
8657 94 tempitem.misc3 = 0;
8658 94 tempitem.misc4 = 0;
8659 94 tempitem.misc5 = 0;
8660 94 tempitem.misc6 = 0;
8661 94 tempitem.misc7 = 0;
8662 94 tempitem.misc8 = 0;
8663 94 tempitem.misc9 = 0;
8664 94 tempitem.misc10 = 0;
8665 94 tempitem.wpn = 0;
8666 94 tempitem.wpn2 = 0;
8667 94 tempitem.wpn3 = 0;
8668 94 tempitem.wpn4 = 0;
8669 94 tempitem.wpn5 = 0;
8670 94 tempitem.wpn6 = 0;
8671 94 tempitem.wpn7 = 0;
8672 94 tempitem.wpn8 = 0;
8673 94 tempitem.wpn9 = 0;
8674 94 tempitem.wpn10 = 0;
8675 94 break;
8676 }
8677 case itype_cbyrna:
8678 {
8679 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8680 92 tempitem.misc4 = 0;
8681 92 tempitem.misc5 = 0;
8682 92 tempitem.misc6 = 0;
8683 92 tempitem.misc7 = 0;
8684 92 tempitem.misc8 = 0;
8685 92 tempitem.misc9 = 0;
8686 92 tempitem.misc10 = 0;
8687 92 tempitem.wpn6 = 0;
8688 92 tempitem.wpn7 = 0;
8689 92 tempitem.wpn8 = 0;
8690 92 tempitem.wpn9 = 0;
8691 92 tempitem.wpn10 = 0;
8692 92 break;
8693 }
8694 case itype_rupee: case itype_arrowammo:
8695 {
8696 1135 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8697 1135 tempitem.misc1 = 0;
8698 1135 tempitem.misc2 = 0;
8699 1135 tempitem.misc3 = 0;
8700 1135 tempitem.misc4 = 0;
8701 1135 tempitem.misc5 = 0;
8702 1135 tempitem.misc6 = 0;
8703 1135 tempitem.misc7 = 0;
8704 1135 tempitem.misc8 = 0;
8705 1135 tempitem.misc9 = 0;
8706 1135 tempitem.misc10 = 0;
8707 1135 tempitem.wpn = 0;
8708 1135 tempitem.wpn2 = 0;
8709 1135 tempitem.wpn3 = 0;
8710 1135 tempitem.wpn4 = 0;
8711 1135 tempitem.wpn5 = 0;
8712 1135 tempitem.wpn6 = 0;
8713 1135 tempitem.wpn7 = 0;
8714 1135 tempitem.wpn8 = 0;
8715 1135 tempitem.wpn9 = 0;
8716 1135 tempitem.wpn10 = 0;
8717 1135 break;
8718 }
8719 case itype_fairy:
8720 {
8721 168 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8722 168 tempitem.misc4 = 0;
8723 168 tempitem.misc5 = 0;
8724 168 tempitem.misc6 = 0;
8725 168 tempitem.misc7 = 0;
8726 168 tempitem.misc8 = 0;
8727 168 tempitem.misc9 = 0;
8728 168 tempitem.misc10 = 0;
8729 168 tempitem.wpn = 0;
8730 168 tempitem.wpn2 = 0;
8731 168 tempitem.wpn3 = 0;
8732 168 tempitem.wpn4 = 0;
8733 168 tempitem.wpn5 = 0;
8734 168 tempitem.wpn6 = 0;
8735 168 tempitem.wpn7 = 0;
8736 168 tempitem.wpn8 = 0;
8737 168 tempitem.wpn9 = 0;
8738 168 tempitem.wpn10 = 0;
8739 168 break;
8740 }
8741 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8742 {
8743 983 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8744 983 tempitem.misc1 = 0;
8745 983 tempitem.misc2 = 0;
8746 983 tempitem.misc3 = 0;
8747 983 tempitem.misc4 = 0;
8748 983 tempitem.misc5 = 0;
8749 983 tempitem.misc6 = 0;
8750 983 tempitem.misc7 = 0;
8751 983 tempitem.misc8 = 0;
8752 983 tempitem.misc9 = 0;
8753 983 tempitem.misc10 = 0;
8754 983 tempitem.wpn = 0;
8755 983 tempitem.wpn2 = 0;
8756 983 tempitem.wpn3 = 0;
8757 983 tempitem.wpn4 = 0;
8758 983 tempitem.wpn5 = 0;
8759 983 tempitem.wpn6 = 0;
8760 983 tempitem.wpn7 = 0;
8761 983 tempitem.wpn8 = 0;
8762 983 tempitem.wpn9 = 0;
8763 983 tempitem.wpn10 = 0;
8764 983 break;
8765 }
8766 case itype_bombbag:
8767 {
8768 368 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8769 368 tempitem.misc3 = 0;
8770 368 tempitem.misc4 = 0;
8771 368 tempitem.misc5 = 0;
8772 368 tempitem.misc6 = 0;
8773 368 tempitem.misc7 = 0;
8774 368 tempitem.misc8 = 0;
8775 368 tempitem.misc9 = 0;
8776 368 tempitem.misc10 = 0;
8777 368 tempitem.wpn = 0;
8778 368 tempitem.wpn2 = 0;
8779 368 tempitem.wpn3 = 0;
8780 368 tempitem.wpn4 = 0;
8781 368 tempitem.wpn5 = 0;
8782 368 tempitem.wpn6 = 0;
8783 368 tempitem.wpn7 = 0;
8784 368 tempitem.wpn8 = 0;
8785 368 tempitem.wpn9 = 0;
8786 368 tempitem.wpn10 = 0;
8787 368 break;
8788 }
8789 case itype_rocs:
8790 {
8791 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8792 92 tempitem.misc1 = 0;
8793 92 tempitem.misc2 = 0;
8794 92 tempitem.misc3 = 0;
8795 92 tempitem.misc4 = 0;
8796 92 tempitem.misc5 = 0;
8797 92 tempitem.misc6 = 0;
8798 92 tempitem.misc7 = 0;
8799 92 tempitem.misc8 = 0;
8800 92 tempitem.misc9 = 0;
8801 92 tempitem.misc10 = 0;
8802 92 tempitem.wpn = 0;
8803 92 tempitem.wpn2 = 0;
8804 92 tempitem.wpn3 = 0;
8805 92 tempitem.wpn4 = 0;
8806 92 tempitem.wpn5 = 0;
8807 92 tempitem.wpn6 = 0;
8808 92 tempitem.wpn7 = 0;
8809 92 tempitem.wpn8 = 0;
8810 92 tempitem.wpn9 = 0;
8811 92 tempitem.wpn10 = 0;
8812 92 break;
8813 }
8814 case itype_hoverboots:
8815 {
8816 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8817 92 tempitem.misc2 = 0;
8818 92 tempitem.misc3 = 0;
8819 92 tempitem.misc4 = 0;
8820 92 tempitem.misc5 = 0;
8821 92 tempitem.misc6 = 0;
8822 92 tempitem.misc7 = 0;
8823 92 tempitem.misc8 = 0;
8824 92 tempitem.misc9 = 0;
8825 92 tempitem.misc10 = 0;
8826 92 tempitem.wpn2 = 0;
8827 92 tempitem.wpn3 = 0;
8828 92 tempitem.wpn4 = 0;
8829 92 tempitem.wpn5 = 0;
8830 92 tempitem.wpn6 = 0;
8831 92 tempitem.wpn7 = 0;
8832 92 tempitem.wpn8 = 0;
8833 92 tempitem.wpn9 = 0;
8834 92 tempitem.wpn10 = 0;
8835 92 break;
8836 }
8837 case itype_spinscroll:
8838 {
8839 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8840 92 tempitem.misc2 = 0;
8841 92 tempitem.misc3 = 0;
8842 92 tempitem.misc4 = 0;
8843 92 tempitem.misc5 = 0;
8844 92 tempitem.misc6 = 0;
8845 92 tempitem.misc7 = 0;
8846 92 tempitem.misc8 = 0;
8847 92 tempitem.misc9 = 0;
8848 92 tempitem.misc10 = 0;
8849 92 tempitem.wpn = 0;
8850 92 tempitem.wpn2 = 0;
8851 92 tempitem.wpn3 = 0;
8852 92 tempitem.wpn4 = 0;
8853 92 tempitem.wpn5 = 0;
8854 92 tempitem.wpn6 = 0;
8855 92 tempitem.wpn7 = 0;
8856 92 tempitem.wpn8 = 0;
8857 92 tempitem.wpn9 = 0;
8858 92 tempitem.wpn10 = 0;
8859 92 break;
8860 }
8861 case itype_crossscroll:
8862 {
8863 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8864 92 tempitem.misc1 = 0;
8865 92 tempitem.misc2 = 0;
8866 92 tempitem.misc3 = 0;
8867 92 tempitem.misc4 = 0;
8868 92 tempitem.misc5 = 0;
8869 92 tempitem.misc6 = 0;
8870 92 tempitem.misc7 = 0;
8871 92 tempitem.misc8 = 0;
8872 92 tempitem.misc9 = 0;
8873 92 tempitem.misc10 = 0;
8874 92 tempitem.wpn = 0;
8875 92 tempitem.wpn2 = 0;
8876 92 tempitem.wpn3 = 0;
8877 92 tempitem.wpn4 = 0;
8878 92 tempitem.wpn5 = 0;
8879 92 tempitem.wpn6 = 0;
8880 92 tempitem.wpn7 = 0;
8881 92 tempitem.wpn8 = 0;
8882 92 tempitem.wpn9 = 0;
8883 92 tempitem.wpn10 = 0;
8884 92 break;
8885 }
8886 case itype_quakescroll:
8887 {
8888 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8889 92 tempitem.misc3 = 0;
8890 92 tempitem.misc4 = 0;
8891 92 tempitem.misc5 = 0;
8892 92 tempitem.misc6 = 0;
8893 92 tempitem.misc7 = 0;
8894 92 tempitem.misc8 = 0;
8895 92 tempitem.misc9 = 0;
8896 92 tempitem.misc10 = 0;
8897 92 tempitem.wpn = 0;
8898 92 tempitem.wpn2 = 0;
8899 92 tempitem.wpn3 = 0;
8900 92 tempitem.wpn4 = 0;
8901 92 tempitem.wpn5 = 0;
8902 92 tempitem.wpn6 = 0;
8903 92 tempitem.wpn7 = 0;
8904 92 tempitem.wpn8 = 0;
8905 92 tempitem.wpn9 = 0;
8906 92 tempitem.wpn10 = 0;
8907 92 break;
8908 }
8909 case itype_whispring:
8910 {
8911 185 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8912 185 tempitem.misc2 = 0;
8913 185 tempitem.misc3 = 0;
8914 185 tempitem.misc4 = 0;
8915 185 tempitem.misc5 = 0;
8916 185 tempitem.misc6 = 0;
8917 185 tempitem.misc7 = 0;
8918 185 tempitem.misc8 = 0;
8919 185 tempitem.misc9 = 0;
8920 185 tempitem.misc10 = 0;
8921 185 tempitem.wpn = 0;
8922 185 tempitem.wpn2 = 0;
8923 185 tempitem.wpn3 = 0;
8924 185 tempitem.wpn4 = 0;
8925 185 tempitem.wpn5 = 0;
8926 185 tempitem.wpn6 = 0;
8927 185 tempitem.wpn7 = 0;
8928 185 tempitem.wpn8 = 0;
8929 185 tempitem.wpn9 = 0;
8930 185 tempitem.wpn10 = 0;
8931 185 break;
8932 }
8933 case itype_chargering:
8934 {
8935 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8936 184 tempitem.misc3 = 0;
8937 184 tempitem.misc4 = 0;
8938 184 tempitem.misc5 = 0;
8939 184 tempitem.misc6 = 0;
8940 184 tempitem.misc7 = 0;
8941 184 tempitem.misc8 = 0;
8942 184 tempitem.misc9 = 0;
8943 184 tempitem.misc10 = 0;
8944 184 tempitem.wpn = 0;
8945 184 tempitem.wpn2 = 0;
8946 184 tempitem.wpn3 = 0;
8947 184 tempitem.wpn4 = 0;
8948 184 tempitem.wpn5 = 0;
8949 184 tempitem.wpn6 = 0;
8950 184 tempitem.wpn7 = 0;
8951 184 tempitem.wpn8 = 0;
8952 184 tempitem.wpn9 = 0;
8953 184 tempitem.wpn10 = 0;
8954 184 break;
8955 }
8956 case itype_perilscroll:
8957 {
8958 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8959 92 tempitem.misc2 = 0;
8960 92 tempitem.misc3 = 0;
8961 92 tempitem.misc4 = 0;
8962 92 tempitem.misc5 = 0;
8963 92 tempitem.misc6 = 0;
8964 92 tempitem.misc7 = 0;
8965 92 tempitem.misc8 = 0;
8966 92 tempitem.misc9 = 0;
8967 92 tempitem.misc10 = 0;
8968 92 tempitem.wpn = 0;
8969 92 tempitem.wpn2 = 0;
8970 92 tempitem.wpn3 = 0;
8971 92 tempitem.wpn4 = 0;
8972 92 tempitem.wpn5 = 0;
8973 92 tempitem.wpn6 = 0;
8974 92 tempitem.wpn7 = 0;
8975 92 tempitem.wpn8 = 0;
8976 92 tempitem.wpn9 = 0;
8977 92 tempitem.wpn10 = 0;
8978 92 break;
8979 }
8980 case itype_wealthmedal:
8981 {
8982 277 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8983 277 tempitem.misc2 = 0;
8984 277 tempitem.misc3 = 0;
8985 277 tempitem.misc4 = 0;
8986 277 tempitem.misc5 = 0;
8987 277 tempitem.misc6 = 0;
8988 277 tempitem.misc7 = 0;
8989 277 tempitem.misc8 = 0;
8990 277 tempitem.misc9 = 0;
8991 277 tempitem.misc10 = 0;
8992 277 tempitem.wpn = 0;
8993 277 tempitem.wpn2 = 0;
8994 277 tempitem.wpn3 = 0;
8995 277 tempitem.wpn4 = 0;
8996 277 tempitem.wpn5 = 0;
8997 277 tempitem.wpn6 = 0;
8998 277 tempitem.wpn7 = 0;
8999 277 tempitem.wpn8 = 0;
9000 277 tempitem.wpn9 = 0;
9001 277 tempitem.wpn10 = 0;
9002 277 break;
9003 }
9004 case itype_heartring:
9005 {
9006 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9007 278 tempitem.misc3 = 0;
9008 278 tempitem.misc4 = 0;
9009 278 tempitem.misc5 = 0;
9010 278 tempitem.misc6 = 0;
9011 278 tempitem.misc7 = 0;
9012 278 tempitem.misc8 = 0;
9013 278 tempitem.misc9 = 0;
9014 278 tempitem.misc10 = 0;
9015 278 tempitem.wpn = 0;
9016 278 tempitem.wpn2 = 0;
9017 278 tempitem.wpn3 = 0;
9018 278 tempitem.wpn4 = 0;
9019 278 tempitem.wpn5 = 0;
9020 278 tempitem.wpn6 = 0;
9021 278 tempitem.wpn7 = 0;
9022 278 tempitem.wpn8 = 0;
9023 278 tempitem.wpn9 = 0;
9024 278 tempitem.wpn10 = 0;
9025 278 break;
9026 }
9027 case itype_magicring:
9028 {
9029 372 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9030 372 tempitem.misc3 = 0;
9031 372 tempitem.misc4 = 0;
9032 372 tempitem.misc5 = 0;
9033 372 tempitem.misc6 = 0;
9034 372 tempitem.misc7 = 0;
9035 372 tempitem.misc8 = 0;
9036 372 tempitem.misc9 = 0;
9037 372 tempitem.misc10 = 0;
9038 372 tempitem.wpn = 0;
9039 372 tempitem.wpn2 = 0;
9040 372 tempitem.wpn3 = 0;
9041 372 tempitem.wpn4 = 0;
9042 372 tempitem.wpn5 = 0;
9043 372 tempitem.wpn6 = 0;
9044 372 tempitem.wpn7 = 0;
9045 372 tempitem.wpn8 = 0;
9046 372 tempitem.wpn9 = 0;
9047 372 tempitem.wpn10 = 0;
9048 372 break;
9049 }
9050 case itype_spinscroll2:
9051 {
9052 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9053 92 tempitem.misc2 = 0;
9054 92 tempitem.misc3 = 0;
9055 92 tempitem.misc4 = 0;
9056 92 tempitem.misc5 = 0;
9057 92 tempitem.misc6 = 0;
9058 92 tempitem.misc7 = 0;
9059 92 tempitem.misc8 = 0;
9060 92 tempitem.misc9 = 0;
9061 92 tempitem.misc10 = 0;
9062 92 tempitem.wpn = 0;
9063 92 tempitem.wpn2 = 0;
9064 92 tempitem.wpn3 = 0;
9065 92 tempitem.wpn4 = 0;
9066 92 tempitem.wpn5 = 0;
9067 92 tempitem.wpn6 = 0;
9068 92 tempitem.wpn7 = 0;
9069 92 tempitem.wpn8 = 0;
9070 92 tempitem.wpn9 = 0;
9071 92 tempitem.wpn10 = 0;
9072 92 break;
9073 }
9074 case itype_quakescroll2:
9075 {
9076 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9077 92 tempitem.misc3 = 0;
9078 92 tempitem.misc4 = 0;
9079 92 tempitem.misc5 = 0;
9080 92 tempitem.misc6 = 0;
9081 92 tempitem.misc7 = 0;
9082 92 tempitem.misc8 = 0;
9083 92 tempitem.misc9 = 0;
9084 92 tempitem.misc10 = 0;
9085 92 tempitem.wpn = 0;
9086 92 tempitem.wpn2 = 0;
9087 92 tempitem.wpn3 = 0;
9088 92 tempitem.wpn4 = 0;
9089 92 tempitem.wpn5 = 0;
9090 92 tempitem.wpn6 = 0;
9091 92 tempitem.wpn7 = 0;
9092 92 tempitem.wpn8 = 0;
9093 92 tempitem.wpn9 = 0;
9094 92 tempitem.wpn10 = 0;
9095 92 break;
9096 }
9097 case itype_agony:
9098 {
9099 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9100 92 tempitem.misc2 = 0;
9101 92 tempitem.misc3 = 0;
9102 92 tempitem.misc4 = 0;
9103 92 tempitem.misc5 = 0;
9104 92 tempitem.misc6 = 0;
9105 92 tempitem.misc7 = 0;
9106 92 tempitem.misc8 = 0;
9107 92 tempitem.misc9 = 0;
9108 92 tempitem.misc10 = 0;
9109 92 tempitem.wpn = 0;
9110 92 tempitem.wpn2 = 0;
9111 92 tempitem.wpn3 = 0;
9112 92 tempitem.wpn4 = 0;
9113 92 tempitem.wpn5 = 0;
9114 92 tempitem.wpn6 = 0;
9115 92 tempitem.wpn7 = 0;
9116 92 tempitem.wpn8 = 0;
9117 92 tempitem.wpn9 = 0;
9118 92 tempitem.wpn10 = 0;
9119 92 break;
9120 }
9121 case itype_stompboots:
9122 {
9123 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9124 92 tempitem.misc1 = 0;
9125 92 tempitem.misc2 = 0;
9126 92 tempitem.misc3 = 0;
9127 92 tempitem.misc4 = 0;
9128 92 tempitem.misc5 = 0;
9129 92 tempitem.misc6 = 0;
9130 92 tempitem.misc7 = 0;
9131 92 tempitem.misc8 = 0;
9132 92 tempitem.misc9 = 0;
9133 92 tempitem.misc10 = 0;
9134 92 tempitem.wpn = 0;
9135 92 tempitem.wpn2 = 0;
9136 92 tempitem.wpn3 = 0;
9137 92 tempitem.wpn4 = 0;
9138 92 tempitem.wpn5 = 0;
9139 92 tempitem.wpn6 = 0;
9140 92 tempitem.wpn7 = 0;
9141 92 tempitem.wpn8 = 0;
9142 92 tempitem.wpn9 = 0;
9143 92 tempitem.wpn10 = 0;
9144 92 break;
9145 }
9146 case itype_whimsicalring:
9147 {
9148 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9149 92 tempitem.misc2 = 0;
9150 92 tempitem.misc3 = 0;
9151 92 tempitem.misc4 = 0;
9152 92 tempitem.misc5 = 0;
9153 92 tempitem.misc6 = 0;
9154 92 tempitem.misc7 = 0;
9155 92 tempitem.misc8 = 0;
9156 92 tempitem.misc9 = 0;
9157 92 tempitem.misc10 = 0;
9158 92 tempitem.wpn = 0;
9159 92 tempitem.wpn2 = 0;
9160 92 tempitem.wpn3 = 0;
9161 92 tempitem.wpn4 = 0;
9162 92 tempitem.wpn5 = 0;
9163 92 tempitem.wpn6 = 0;
9164 92 tempitem.wpn7 = 0;
9165 92 tempitem.wpn8 = 0;
9166 92 tempitem.wpn9 = 0;
9167 92 tempitem.wpn10 = 0;
9168 92 break;
9169 }
9170 case itype_perilring:
9171 {
9172 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9173 93 tempitem.misc2 = 0;
9174 93 tempitem.misc3 = 0;
9175 93 tempitem.misc4 = 0;
9176 93 tempitem.misc5 = 0;
9177 93 tempitem.misc6 = 0;
9178 93 tempitem.misc7 = 0;
9179 93 tempitem.misc8 = 0;
9180 93 tempitem.misc9 = 0;
9181 93 tempitem.misc10 = 0;
9182 93 tempitem.wpn = 0;
9183 93 tempitem.wpn2 = 0;
9184 93 tempitem.wpn3 = 0;
9185 93 tempitem.wpn4 = 0;
9186 93 tempitem.wpn5 = 0;
9187 93 tempitem.wpn6 = 0;
9188 93 tempitem.wpn7 = 0;
9189 93 tempitem.wpn8 = 0;
9190 93 tempitem.wpn9 = 0;
9191 93 tempitem.wpn10 = 0;
9192 93 break;
9193 }
9194 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9195 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9196 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9197 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9198 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9199 {
9200 2541 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9201 2541 tempitem.misc1 = 0;
9202 2541 tempitem.misc2 = 0;
9203 2541 tempitem.misc3 = 0;
9204 2541 tempitem.misc4 = 0;
9205 2541 tempitem.misc5 = 0;
9206 2541 tempitem.misc6 = 0;
9207 2541 tempitem.misc7 = 0;
9208 2541 tempitem.misc8 = 0;
9209 2541 tempitem.misc9 = 0;
9210 2541 tempitem.misc10 = 0;
9211 2541 tempitem.wpn = 0;
9212 2541 tempitem.wpn2 = 0;
9213 2541 tempitem.wpn3 = 0;
9214 2541 tempitem.wpn4 = 0;
9215 2541 tempitem.wpn5 = 0;
9216 2541 tempitem.wpn6 = 0;
9217 2541 tempitem.wpn7 = 0;
9218 2541 tempitem.wpn8 = 0;
9219 2541 tempitem.wpn9 = 0;
9220 2541 tempitem.wpn10 = 0;
9221 2541 break;
9222 }
9223 }
9224 23808 }
9225 //Port quest rules to items
9226
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version <= 31)
9227 {
9228
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_bomb)
9229 {
9230
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 90 times.
107 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9231 90 else tempitem.flags &= ~ ITEM_FLAG2;
9232 107 }
9233
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23609 times.
23701 else if(tempitem.family == itype_sbomb)
9234 {
9235
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 75 times.
92 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9236 75 else tempitem.flags &= ~ ITEM_FLAG2;
9237 92 }
9238
9239
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 23332 times.
23609 else if(tempitem.family == itype_brang)
9240 {
9241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9242 277 else tempitem.flags &= ~ ITEM_FLAG4;
9243 277 }
9244
2/2
✓ Branch 0 taken 23225 times.
✓ Branch 1 taken 107 times.
23332 else if(tempitem.family == itype_wand)
9245 {
9246
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9247 105 else tempitem.flags &= ~ ITEM_FLAG3;
9248 107 }
9249 23808 }
9250
9251 //Port quest rules to items
9252
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version <= 37)
9253 {
9254
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23715 times.
23808 if(tempitem.family == itype_flippers)
9255 {
9256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9257 93 else tempitem.flags &= ~ ITEM_FLAG1;
9258 93 }
9259
2/2
✓ Branch 0 taken 15904 times.
✓ Branch 1 taken 7811 times.
23715 else if(tempitem.family == itype_sword)
9260 {
9261
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9262 7742 else tempitem.flags &= ~ ITEM_FLAG5;
9263 7811 }
9264
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 15797 times.
15904 else if(tempitem.family == itype_wand)
9265 {
9266
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104 times.
107 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9267 104 else tempitem.flags &= ~ ITEM_FLAG5;
9268 107 }
9269
4/4
✓ Branch 0 taken 15690 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 15468 times.
15797 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9270 {
9271 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9272
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 257 times.
329 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9273 257 else tempitem.flags &= ~ ITEM_FLAG3;
9274 329 }
9275 23808 }
9276
9277
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 38)
9278 {
9279
4/4
✓ Branch 0 taken 23531 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 23347 times.
23808 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9280 {
9281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9282 461 else tempitem.flags &= ~ITEM_FLAG4;
9283
9284
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450 times.
461 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9285 450 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9286 461 }
9287
2/2
✓ Branch 0 taken 23073 times.
✓ Branch 1 taken 274 times.
23347 else if(tempitem.family == itype_arrow)
9288 {
9289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9290 274 else tempitem.flags &= ~ITEM_FLAG4;
9291
9292
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 270 times.
274 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9293 270 else tempitem.flags |= ITEM_FLAG2;
9294 274 }
9295 23808 }
9296
9297
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 39)
9298 {
9299
6/6
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 23609 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 222 times.
✓ Branch 5 taken 23387 times.
23808 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9300 {
9301
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 409 times.
421 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9302 409 else tempitem.flags &= ~ITEM_FLAG5;
9303 421 }
9304
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 23204 times.
23387 else if(tempitem.family == itype_potion)
9305 {
9306
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 159 times.
183 if(get_qr(qr_NONBUBBLEMEDICINE))
9307 {
9308 24 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9309 24 }
9310 else
9311 {
9312 159 tempitem.flags |= ITEM_FLAG3;
9313
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 74 times.
159 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9314 74 else tempitem.flags &= ~ITEM_FLAG4;
9315 }
9316 183 }
9317
2/2
✓ Branch 0 taken 23020 times.
✓ Branch 1 taken 184 times.
23204 else if(tempitem.family == itype_triforcepiece)
9318 {
9319
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 154 times.
184 if(get_qr(qr_NONBUBBLETRIFORCE))
9320 {
9321 30 tempitem.flags |= ITEM_FLAG3;
9322
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9323 24 else tempitem.flags &= ~ITEM_FLAG4;
9324 30 }
9325 else
9326 {
9327 154 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9328 }
9329 184 }
9330 23808 }
9331
9332
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 40)
9333 {
9334
4/4
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 23413 times.
23808 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9335 {
9336
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 348 times.
395 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9337 348 else tempitem.flags &= ~ITEM_FLAG1;
9338 395 }
9339
8/8
✓ Branch 0 taken 23191 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 15380 times.
✓ Branch 3 taken 7811 times.
✓ Branch 4 taken 15273 times.
✓ Branch 5 taken 107 times.
✓ Branch 6 taken 92 times.
✓ Branch 7 taken 15181 times.
23413 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9340 {
9341
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 8151 times.
8232 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9342 8151 else tempitem.flags &= ~ITEM_FLAG8;
9343 8232 }
9344
6/6
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 15890 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 15797 times.
23808 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9345 {
9346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9347 8011 else tempitem.flags &= ~ITEM_FLAG7;
9348 8011 }
9349
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 92 times.
15797 else if(tempitem.family == itype_cbyrna)
9350 {
9351 92 tempitem.flags |= ITEM_FLAG7;
9352 92 }
9353 23808 }
9354
9355
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 41 )
9356 {
9357
2/2
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
23808 if(tempitem.family == itype_sword)
9358 {
9359
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9360 7742 else tempitem.flags &= ~ITEM_FLAG9;
9361
9362
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9363 7742 else tempitem.flags &= ~ITEM_FLAG10;
9364 7811 }
9365 23808 }
9366
9367
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 42 )
9368 {
9369
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_wand)
9370 {
9371
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9372 105 else tempitem.flags &= ~ITEM_FLAG3;
9373
9374 107 tempitem.flags &= ~ITEM_FLAG6;
9375 107 }
9376
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23608 times.
23701 else if(tempitem.family == itype_hammer)
9377 {
9378 93 tempitem.flags &= ~ITEM_FLAG3;
9379 93 }
9380
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23516 times.
23608 else if(tempitem.family == itype_cbyrna)
9381 {
9382 92 tempitem.flags |= ITEM_FLAG3;
9383
9384 92 tempitem.flags &= ~ITEM_FLAG6;
9385 92 }
9386
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 7811 times.
23516 else if(tempitem.family == itype_sword)
9387 {
9388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7811 times.
7811 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9389 7811 else tempitem.flags &= ~ITEM_FLAG6;
9390 7811 }
9391 23808 }
9392
9393
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 43 )
9394 {
9395
2/2
✓ Branch 0 taken 23670 times.
✓ Branch 1 taken 138 times.
23808 if(tempitem.family == itype_whistle)
9396 {
9397
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 135 times.
138 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9398 135 else tempitem.flags &= ~ITEM_FLAG3;
9399 138 }
9400 23808 }
9401
9402
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 45 )
9403 {
9404
2/2
✓ Branch 0 taken 23715 times.
✓ Branch 1 taken 93 times.
23808 if(tempitem.family == itype_flippers)
9405 {
9406 93 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9407 93 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9408 93 }
9409 23808 }
9410
9411
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 46 )
9412 {
9413
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if(tempitem.family == itype_raft)
9414 {
9415 92 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9416 92 }
9417 23808 }
9418
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 34 ) //! set the default counter for older quests.
9419 {
9420
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 23733 times.
23808 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9421 {
9422 75 tempitem.cost_counter[0] = 1;
9423 75 }
9424 else
9425 {
9426
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 19125 times.
23733 if(get_qr(qr_ENABLEMAGIC))
9427 4608 tempitem.cost_counter[0] = 4;
9428 else
9429 {
9430 19125 tempitem.cost_amount[0] = 0;
9431 19125 tempitem.cost_counter[0] = -1;
9432 }
9433 }
9434 23808 }
9435
9436
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 35 ) //new Lens of Truth flags
9437 {
9438
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if ( tempitem.family == itype_lens )
9439 {
9440
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3 times.
92 if ( get_qr(qr_RAFTLENS) )
9441 {
9442 3 tempitem.flags |= ITEM_FLAG4;
9443 3 }
9444
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 52 times.
92 if ( get_qr(qr_LENSHINTS) )
9445 {
9446 52 tempitem.flags |= ITEM_FLAG1;
9447 52 }
9448
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4 times.
92 if ( get_qr(qr_LENSSEESENEMIES) )
9449 {
9450 4 tempitem.flags |= ITEM_FLAG5;
9451 4 }
9452 92 }
9453 23808 }
9454
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9455 {
9456
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 23808 times.
214272 for ( int32_t q = 0; q < 8; q++ )
9457 {
9458 190464 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9459 190464 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9460 190464 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9461 190464 tempitem.sprite_initiald[q] = 0;
9462 190464 }
9463
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 23808 times.
71424 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9464 23808 tempitem.sprite_script = 0;
9465 23808 }
9466
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9467 {
9468 23808 tempitem.pickupflag = 0;
9469 23808 }
9470
9471
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 51 )
9472 {
9473
2/2
✓ Branch 0 taken 23586 times.
✓ Branch 1 taken 222 times.
23808 if( tempitem.family == itype_candle )
9474 {
9475 222 tempitem.misc4 = 50; //Step speed
9476 222 }
9477 23808 }
9478
9479
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 52 )
9480 {
9481
2/2
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 283 times.
23808 if( tempitem.family == itype_shield )
9482 283 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9483 23808 }
9484
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if(s_version < 53)
9485 {
9486
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23335 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 92 times.
23808 switch(tempitem.family)
9487 {
9488 case itype_arrow:
9489 274 tempitem.cost_counter[1] = crARROWS;
9490 274 tempitem.cost_amount[1] = 1;
9491 274 break;
9492 case itype_bomb:
9493 107 tempitem.cost_counter[1] = crBOMBS;
9494 107 tempitem.cost_amount[1] = 1;
9495 107 break;
9496 case itype_sbomb:
9497 92 tempitem.cost_counter[1] = crSBOMBS;
9498 92 tempitem.cost_amount[1] = 1;
9499 92 break;
9500 default:
9501 23335 tempitem.cost_counter[1] = crNONE;
9502 23335 tempitem.cost_amount[1] = 0;
9503 23335 }
9504 23808 tempitem.magiccosttimer[1] = 0;
9505 23808 }
9506
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 24832 times.
33024 if( s_version < 54 )
9507 {
9508
2/2
✓ Branch 0 taken 24735 times.
✓ Branch 1 taken 97 times.
24832 if( tempitem.family == itype_flippers )
9509 97 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9510 24832 }
9511
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 24832 times.
33024 if(s_version < 55)
9512 {
9513
3/3
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 24448 times.
24832 switch(tempitem.family)
9514 {
9515 case itype_spinscroll:
9516 case itype_quakescroll:
9517 192 tempitem.usesound2 = WAV_ZN1CHARGE;
9518 192 break;
9519 case itype_spinscroll2:
9520 case itype_quakescroll2:
9521 192 tempitem.usesound2 = WAV_ZN1CHARGE2;
9522 192 break;
9523 }
9524 24832 }
9525
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 24832 times.
33024 if(s_version < 56)
9526 {
9527
4/4
✓ Branch 0 taken 24395 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 230 times.
✓ Branch 3 taken 111 times.
24832 switch(tempitem.family)
9528 {
9529 case itype_divinefire:
9530
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 4 times.
96 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9531
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 80 times.
96 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9532 96 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9533 96 break;
9534 case itype_candle:
9535
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 119 times.
230 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9536 230 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9537 230 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9538 230 break;
9539 case itype_book:
9540 111 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9541 111 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9542 111 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9543 111 break;
9544 }
9545 24832 }
9546
9547
2/2
✓ Branch 0 taken 30880 times.
✓ Branch 1 taken 2144 times.
33024 if(tempitem.fam_type==0) // Always do this
9548 2144 tempitem.fam_type=1;
9549
9550 33024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9551 33024 }
9552
9553 129 return 0;
9554 129 }
9555
9556 static bool did_init_def_items = false;
9557 66240 void init_def_items()
9558 {
9559
2/2
✓ Branch 0 taken 66125 times.
✓ Branch 1 taken 115 times.
66240 if(did_init_def_items) return;
9560 115 did_init_def_items = true;
9561 115 default_items[3].cost_counter[1] = crBOMBS;
9562 115 default_items[13].cost_counter[1] = crARROWS;
9563 115 default_items[14].cost_counter[1] = crARROWS;
9564 115 default_items[48].cost_counter[1] = crSBOMBS;
9565 115 default_items[57].cost_counter[1] = crARROWS;
9566 66240 }
9567 66240 void reset_itembuf(itemdata *item, int32_t id)
9568 {
9569 66240 init_def_items();
9570
2/2
✓ Branch 0 taken 28250 times.
✓ Branch 1 taken 37990 times.
66240 if(id<iLast)
9571 {
9572 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9573 37990 word tile = item->tile;
9574 37990 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9575 37990 int32_t ltm = item->ltm;
9576
9577 37990 memcpy(item,&default_items[id],sizeof(itemdata));
9578 37990 item->tile = tile;
9579 37990 item->misc_flags = miscs;
9580 37990 item->csets = cset;
9581 37990 item->frames = frames;
9582 37990 item->speed = speed;
9583 37990 item->delay = delay;
9584 37990 item->ltm = ltm;
9585 37990 }
9586 66240 }
9587
9588 33536 void reset_itemname(int32_t id)
9589 {
9590 33536 sprintf(item_string[id],"zz%03d",id);
9591
9592
2/2
✓ Branch 0 taken 14803 times.
✓ Branch 1 taken 18733 times.
33536 if(id < iLast)
9593 18733 strcpy(item_string[id],old_item_string[id]);
9594 33536 }
9595
9596 129 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9597 {
9598 129 word weapons_to_read=MAXWPNS;
9599 int32_t dummy;
9600 byte padding;
9601 wpndata tempweapon;
9602 129 word s_version=0, s_cversion=0;
9603
9604
9605
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x186)
9606 {
9607 weapons_to_read=64;
9608 }
9609
9610
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x185)
9611 {
9612 weapons_to_read=32;
9613 }
9614
9615
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
9616 {
9617 125 weapons_to_read=0;
9618
9619 //section version info
9620
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
9621 {
9622 return qe_invalid;
9623 }
9624
9625 125 FFCore.quest_format[vWeaponSprites] = s_version;
9626
9627 //al_trace("Weapons version %d\n", s_version);
9628
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
9629 {
9630 return qe_invalid;
9631 }
9632
9633 //section size
9634
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
9635 {
9636 return qe_invalid;
9637 }
9638
9639 //finally... section data
9640
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&weapons_to_read,f))
9641 {
9642 return qe_invalid;
9643 }
9644
9645
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9646 {
9647 return qe_invalid;
9648 }
9649 125 }
9650
9651
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version>2)
9652 {
9653
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<weapons_to_read; i++)
9654 {
9655 char tempname[64];
9656
9657
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!pfread(tempname, 64, f))
9658 {
9659 return qe_invalid;
9660 }
9661
9662 28928 weapon_string[i][0] = '\0';
9663 28928 strncat(weapon_string[i], tempname, 64 - 1);
9664 28928 }
9665
9666
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version<4)
9667 {
9668 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9669 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9670 }
9671
9672
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version<5)
9673 {
9674 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9675 }
9676
9677 /*
9678 if (s_version<6)
9679 {
9680 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9681 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9682 }
9683 */
9684 113 }
9685 else
9686 {
9687
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXWPNS; i++)
9688 4096 reset_weaponname(i);
9689 }
9690
9691
2/2
✓ Branch 0 taken 30768 times.
✓ Branch 1 taken 129 times.
30897 for(int32_t i=0; i<weapons_to_read; i++)
9692 {
9693 30768 word oldtile = 0;
9694
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 22064 times.
30768 if (s_version < 8)
9695 {
9696
1/2
✓ Branch 0 taken 22064 times.
✗ Branch 1 not taken.
22064 if (!p_igetw(&oldtile, f))
9697 return qe_invalid;
9698 22064 }
9699
9700
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.misc,f))
9701 {
9702 return qe_invalid;
9703 }
9704
9705
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.csets,f))
9706 {
9707 return qe_invalid;
9708 }
9709
9710
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.frames,f))
9711 {
9712 return qe_invalid;
9713 }
9714
9715
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.speed,f))
9716 {
9717 return qe_invalid;
9718 }
9719
9720
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.type,f))
9721 {
9722 return qe_invalid;
9723 }
9724
9725
2/2
✓ Branch 0 taken 21552 times.
✓ Branch 1 taken 9216 times.
30768 if ( s_version >= 7 )
9726 {
9727
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempweapon.script,f))
9728 {
9729 return qe_invalid;
9730 }
9731
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempweapon.tile,f))
9732 {
9733 return qe_invalid;
9734 }
9735 9216 }
9736
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 21552 times.
30768 if ( s_version < 7 )
9737 {
9738 21552 tempweapon.tile = oldtile;
9739 21552 }
9740
9741
2/2
✓ Branch 0 taken 29744 times.
✓ Branch 1 taken 1024 times.
30768 if(Header->zelda_version < 0x193)
9742 {
9743
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
9744 {
9745 return qe_invalid;
9746 }
9747 1024 }
9748
9749
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 1840 times.
30768 if(s_version < 6)
9750 {
9751
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1836 times.
1840 if(i==ewFIRETRAIL)
9752 {
9753 4 tempweapon.misc |= WF_BEHIND;
9754 4 }
9755 else
9756 1836 tempweapon.misc &= ~WF_BEHIND;
9757 1840 }
9758
9759 30768 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9760 30768 }
9761
9762
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<2)
9763 {
9764 16 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9765 16 }
9766
9767
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<5)
9768 {
9769 16 wpnsbuf[iwQuarterHearts].tile=1;
9770 16 wpnsbuf[iwQuarterHearts].csets=1;
9771 16 }
9772
9773
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x176)
9774 {
9775 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9776 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9777 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9778 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9779 }
9780
9781
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
9782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9783 {
9784 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9785 4 }
9786
9787
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if((Header->zelda_version < 0x210))
9788 {
9789 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9790 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9791 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9792 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9793 4 }
9794
9795 129 return 0;
9796 129 }
9797
9798 129 void init_guys(int32_t guyversion)
9799 {
9800
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<MAXGUYS; i++)
9801 {
9802 66048 guysbuf[i] = default_guys[0];
9803 66048 }
9804
9805
2/2
✓ Branch 0 taken 22833 times.
✓ Branch 1 taken 129 times.
22962 for(int32_t i=0; i<OLDMAXGUYS; i++)
9806 {
9807 22833 guysbuf[i] = default_guys[i];
9808
2/2
✓ Branch 0 taken 22575 times.
✓ Branch 1 taken 258 times.
22833 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9809 22833 guysbuf[i].spr_death = iwDeath;
9810 22833 guysbuf[i].spr_spawn = iwSpawn;
9811 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9812
4/4
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 20001 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 16 times.
22833 if(guyversion<=3 && i==ePATRABS)
9813 {
9814 16 guysbuf[i].bosspal=spDIG;
9815 16 guysbuf[i].cset=14;
9816 16 guysbuf[i].misc9=14;
9817 16 }
9818
9819
2/2
✓ Branch 0 taken 20001 times.
✓ Branch 1 taken 2832 times.
22833 if(guyversion<=3)
9820 {
9821 // Rope/Ghini Flash rules
9822
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2124 times.
2832 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9823 {
9824
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 if(i==eROPE2)
9825 {
9826 12 guysbuf[i].flags2 &= ~guy_flashing;
9827 12 }
9828 2124 }
9829
9830
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 531 times.
2832 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9831 {
9832
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9833 {
9834 18 guysbuf[i].flags2 &= ~guy_flashing;
9835 18 }
9836 531 }
9837
9838
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 16 times.
2832 if(i==eGHINI2)
9839 {
9840
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9841 {
9842 3 guysbuf[i].flags2 |= guy_blinking;
9843 3 }
9844
9845
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9846 {
9847 guysbuf[i].flags2 |= guy_transparent;
9848 }
9849 16 }
9850 2832 }
9851
9852 // Darknut fix
9853
10/10
✓ Branch 0 taken 22704 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 22575 times.
✓ Branch 3 taken 129 times.
✓ Branch 4 taken 22446 times.
✓ Branch 5 taken 129 times.
✓ Branch 6 taken 22317 times.
✓ Branch 7 taken 129 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 22188 times.
22833 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9854 {
9855
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 210 times.
645 if(get_qr(qr_NEWENEMYTILES))
9856 {
9857 435 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9858 435 guysbuf[i].s_width=guysbuf[i].e_width;
9859 435 guysbuf[i].s_height=guysbuf[i].e_height;
9860 435 }
9861 210 else guysbuf[i].s_tile=860;
9862
9863
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 80 times.
645 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9864 {
9865 80 guysbuf[i].flags |= guy_bkshield;
9866 80 }
9867 645 }
9868
9869
4/4
✓ Branch 0 taken 22704 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 22825 times.
✓ Branch 3 taken 8 times.
22833 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9870 {
9871 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9872 8 }
9873 22833 }
9874 129 }
9875
9876 4096 void reset_weaponname(int32_t i)
9877 {
9878
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 2688 times.
4096 if(i<wLast)
9879 {
9880 1408 strcpy(weapon_string[i],old_weapon_string[i]);
9881 1408 }
9882 else
9883 2688 sprintf(weapon_string[i],"zz%03d",i);
9884 4096 }
9885
9886 129 void init_item_drop_sets()
9887 {
9888
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9889 {
9890 // item_drop_sets[i] = default_item_drop_sets[0];
9891 33024 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9892 33024 }
9893
9894
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 129 times.
1806 for(int32_t i=0; i<isMAX; i++)
9895 {
9896 1677 item_drop_sets[i] = default_item_drop_sets[i];
9897
9898 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9899
2/2
✓ Branch 0 taken 16770 times.
✓ Branch 1 taken 1677 times.
18447 for(int32_t j=0; j<10; ++j)
9900 {
9901 16770 int32_t it = item_drop_sets[i].item[j];
9902
9903
3/4
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 4994 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 756 times.
16770 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9904
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 11020 times.
11776 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9905 {
9906 756 item_drop_sets[i].chance[j+1]=0;
9907 756 }
9908
3/4
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 15498 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 516 times.
16014 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9909 {
9910 item_drop_sets[i].chance[j+1]=0;
9911 }
9912
9913 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9914
2/2
✓ Branch 0 taken 16762 times.
✓ Branch 1 taken 8 times.
16770 if(itemsbuf[it].family == itype_misc)
9915 {
9916 // If a non-gameplay item was selected, then item drop was aborted.
9917 // Reflect this by increasing the 'Nothing' chance accordingly.
9918 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9919 8 item_drop_sets[i].chance[j+1]=0;
9920 8 }
9921 16770 }
9922 1677 }
9923 129 }
9924
9925 125 void init_favorites()
9926 {
9927
2/2
✓ Branch 0 taken 37500 times.
✓ Branch 1 taken 125 times.
37625 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9928 {
9929 37500 favorite_combos[i]=-1;
9930 37500 }
9931
9932
2/2
✓ Branch 0 taken 37500 times.
✓ Branch 1 taken 125 times.
37625 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9933 {
9934 37500 favorite_comboaliases[i]=-1;
9935 37500 }
9936 125 }
9937
9938 const char *ctype_name[cMAX]=
9939 {
9940 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9941 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9942 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9943 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9944 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9945 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9946 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9947 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9948 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9949 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9950 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9951 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9952 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9953 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9954 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9955 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9956 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9957 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9958 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9959 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9960 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9961 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9962 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9963 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9964 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9965 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9966 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9967 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9968
9969 };
9970
9971 224 int32_t init_combo_classes()
9972 {
9973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 224 times.
224 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9974
2/2
✓ Branch 0 taken 40768 times.
✓ Branch 1 taken 224 times.
40992 for(int32_t i=0; i<cMAX; i++)
9975 {
9976 40768 combo_class_buf[i] = default_combo_classes[i];
9977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40768 times.
40768 if ( char const* nm = zi->getComboTypeName(i) )
9978 {
9979 40768 size_t len = strlen(nm);
9980
2/2
✓ Branch 0 taken 2609152 times.
✓ Branch 1 taken 40768 times.
2649920 for ( size_t q = 0; q < 64; q++ )
9981 {
9982
2/2
✓ Branch 0 taken 598528 times.
✓ Branch 1 taken 2010624 times.
2609152 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9983 2609152 }
9984 40768 }
9985 40768 }
9986
9987 224 return 0;
9988 }
9989
9990 97 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9991 {
9992
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 assert(v_herosprites < 6);
9993 //these are here to bypass compiler warnings about unused arguments
9994 97 cv_herosprites=cv_herosprites;
9995
9996 97 zinit.hero_swim_speed=67; //default
9997 97 setupherotiles(zinit.heroAnimationStyle);
9998 97 setupherodefenses();
9999 97 setupherooffsets();
10000
10001
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 77 times.
97 if(v_herosprites>=0)
10002 {
10003 word tile, tile2;
10004 byte flip, extend, dummy_byte;
10005
10006
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10007 {
10008
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10009 {
10010 return qe_invalid;
10011 }
10012
10013
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10014 {
10015 return qe_invalid;
10016 }
10017
10018
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10019 {
10020 return qe_invalid;
10021 }
10022
10023 308 walkspr[i][spr_tile]=(int32_t)tile;
10024 308 walkspr[i][spr_flip]=(int32_t)flip;
10025 308 walkspr[i][spr_extend]=(int32_t)extend;
10026 308 }
10027
10028
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10029 {
10030
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10031 {
10032 return qe_invalid;
10033 }
10034
10035
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10036 {
10037 return qe_invalid;
10038 }
10039
10040
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10041 {
10042 return qe_invalid;
10043 }
10044
10045 308 stabspr[i][spr_tile]=(int32_t)tile;
10046 308 stabspr[i][spr_flip]=(int32_t)flip;
10047 308 stabspr[i][spr_extend]=(int32_t)extend;
10048 308 }
10049
10050
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10051 {
10052
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10053 {
10054 return qe_invalid;
10055 }
10056
10057
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10058 {
10059 return qe_invalid;
10060 }
10061
10062
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10063 {
10064 return qe_invalid;
10065 }
10066
10067 308 slashspr[i][spr_tile]=(int32_t)tile;
10068 308 slashspr[i][spr_flip]=(int32_t)flip;
10069 308 slashspr[i][spr_extend]=(int32_t)extend;
10070 308 }
10071
10072
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10073 {
10074
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10075 {
10076 return qe_invalid;
10077 }
10078
10079
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10080 {
10081 return qe_invalid;
10082 }
10083
10084
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10085 {
10086 return qe_invalid;
10087 }
10088
10089 308 floatspr[i][spr_tile]=(int32_t)tile;
10090 308 floatspr[i][spr_flip]=(int32_t)flip;
10091 308 floatspr[i][spr_extend]=(int32_t)extend;
10092 308 }
10093
10094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>1)
10095 {
10096
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10097 {
10098
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10099 {
10100 return qe_invalid;
10101 }
10102
10103
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10104 {
10105 return qe_invalid;
10106 }
10107
10108
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10109 {
10110 return qe_invalid;
10111 }
10112
10113 308 swimspr[i][spr_tile]=(int32_t)tile;
10114 308 swimspr[i][spr_flip]=(int32_t)flip;
10115 308 swimspr[i][spr_extend]=(int32_t)extend;
10116 308 }
10117 77 }
10118
10119
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10120 {
10121
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10122 {
10123 return qe_invalid;
10124 }
10125
10126
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10127 {
10128 return qe_invalid;
10129 }
10130
10131
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10132 {
10133 return qe_invalid;
10134 }
10135
10136 308 divespr[i][spr_tile]=(int32_t)tile;
10137 308 divespr[i][spr_flip]=(int32_t)flip;
10138 308 divespr[i][spr_extend]=(int32_t)extend;
10139 308 }
10140
10141
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10142 {
10143
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10144 {
10145 return qe_invalid;
10146 }
10147
10148
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10149 {
10150 return qe_invalid;
10151 }
10152
10153
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10154 {
10155 return qe_invalid;
10156 }
10157
10158 308 poundspr[i][spr_tile]=(int32_t)tile;
10159 308 poundspr[i][spr_flip]=(int32_t)flip;
10160 308 poundspr[i][spr_extend]=(int32_t)extend;
10161 308 }
10162
10163
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tile,f))
10164 {
10165 return qe_invalid;
10166 }
10167
10168 77 flip=0;
10169
10170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>0)
10171 {
10172
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&flip,f))
10173 {
10174 return qe_invalid;
10175 }
10176 77 }
10177
10178
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&extend,f))
10179 {
10180 return qe_invalid;
10181 }
10182
10183 77 castingspr[spr_tile]=(int32_t)tile;
10184 77 castingspr[spr_flip]=(int32_t)flip;
10185 77 castingspr[spr_extend]=(int32_t)extend;
10186
10187
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(v_herosprites>0)
10188 {
10189 77 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10190
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 77 times.
231 for(int32_t i=0; i<2; i++)
10191 {
10192
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 154 times.
462 for(int32_t j=0; j<num_holdsprs; j++)
10193 {
10194
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10195 {
10196 return qe_invalid;
10197 }
10198
10199
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10200 {
10201 return qe_invalid;
10202 }
10203
10204
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10205 {
10206 return qe_invalid;
10207 }
10208
10209 308 holdspr[i][j][spr_tile]=(int32_t)tile;
10210 308 holdspr[i][j][spr_flip]=(int32_t)flip;
10211 308 holdspr[i][j][spr_extend]=(int32_t)extend;
10212 308 }
10213 154 }
10214 77 }
10215 else
10216 {
10217 for(int32_t i=0; i<2; i++)
10218 {
10219 if(!p_igetw(&tile,f))
10220 {
10221 return qe_invalid;
10222 }
10223
10224 if(!p_igetw(&tile2,f))
10225 {
10226 return qe_invalid;
10227 }
10228
10229 if(!p_getc(&extend,f))
10230 {
10231 return qe_invalid;
10232 }
10233
10234 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10235 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10236 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10237 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10238 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10239 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10240 }
10241 }
10242
10243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>2)
10244 {
10245
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10246 {
10247
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10248 {
10249 return qe_invalid;
10250 }
10251
10252
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10253 {
10254 return qe_invalid;
10255 }
10256
10257
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10258 {
10259 return qe_invalid;
10260 }
10261
10262 308 jumpspr[i][spr_tile]=(int32_t)tile;
10263 308 jumpspr[i][spr_flip]=(int32_t)flip;
10264 308 jumpspr[i][spr_extend]=(int32_t)extend;
10265 308 }
10266 77 }
10267
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>3)
10269 {
10270
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10271 {
10272
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10273 {
10274 return qe_invalid;
10275 }
10276
10277
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10278 {
10279 return qe_invalid;
10280 }
10281
10282
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10283 {
10284 return qe_invalid;
10285 }
10286
10287 308 chargespr[i][spr_tile]=(int32_t)tile;
10288 308 chargespr[i][spr_flip]=(int32_t)flip;
10289 308 chargespr[i][spr_extend]=(int32_t)extend;
10290 308 }
10291 77 }
10292
10293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>4)
10294 {
10295
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&dummy_byte,f))
10296 {
10297 return qe_invalid;
10298 }
10299
10300 77 zinit.hero_swim_speed=(byte)dummy_byte;
10301 77 }
10302
10303 77 memset(frozenspr, 0, sizeof(frozenspr));
10304 77 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10305 77 memset(onfirespr, 0, sizeof(onfirespr));
10306 77 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10307 77 memset(diggingspr, 0, sizeof(diggingspr));
10308 77 memset(usingrodspr, 0, sizeof(usingrodspr));
10309 77 memset(usingcanespr, 0, sizeof(usingcanespr));
10310 77 memset(pushingspr, 0, sizeof(pushingspr));
10311 77 memset(liftingspr, 0, sizeof(liftingspr));
10312 77 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10313 77 memset(stunnedspr, 0, sizeof(stunnedspr));
10314 77 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10315 77 memset(fallingspr, 0, sizeof(fallingspr));
10316 77 memset(shockedspr, 0, sizeof(shockedspr));
10317 77 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10318 77 memset(pullswordspr, 0, sizeof(pullswordspr));
10319 77 memset(readingspr, 0, sizeof(readingspr));
10320 77 memset(slash180spr, 0, sizeof(slash180spr));
10321 77 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10322 77 memset(dashspr, 0, sizeof(dashspr));
10323 77 memset(bonkspr, 0, sizeof(bonkspr));
10324 77 memset(medallionsprs, 0, sizeof(medallionsprs));
10325 77 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10326 77 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10327
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t q = 0; q < 4; ++q)
10328 {
10329
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 308 times.
1232 for(int32_t p = 0; p < 3; ++p)
10330 {
10331 924 drowningspr[q][p] = divespr[q][p];
10332 924 drowning_lavaspr[q][p] = divespr[q][p];
10333 924 }
10334 308 }
10335 77 memset(sideswimspr, 0, sizeof(sideswimspr));
10336 77 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10337 77 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10338 77 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10339 77 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10340 77 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10341 77 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10342 77 }
10343
10344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(FFCore.quest_format[vInitData] < 34)
10345 {
10346 97 bool fastswim = zinit.hero_swim_speed > 60;
10347 // '2/3' or '1/2'
10348 97 zinit.hero_swim_mult = fastswim ? 2 : 1;
10349 97 zinit.hero_swim_div = fastswim ? 3 : 2;
10350 97 }
10351 97 return 0;
10352 97 }
10353
10354 6120 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10355 {
10356 6120 arr[spr_tile] = tile;
10357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6120 times.
6120 arr[spr_flip] = (flip > 3 ? 0 : flip);
10358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6120 times.
6120 arr[spr_extend] = (ext > 2 ? 0 : ext);
10359 6120 }
10360 //Used to read the player sprites as int32_t, not word.
10361 36 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10362 {
10363 //these are here to bypass compiler warnings about unused arguments
10364 36 cv_herosprites=cv_herosprites;
10365
10366 36 zinit.hero_swim_speed=67; //default
10367 36 setupherotiles(zinit.heroAnimationStyle);
10368 36 setupherodefenses();
10369 36 setupherooffsets();
10370
10371 int32_t tile, tile2;
10372 byte flip, extend, dummy_byte;
10373
10374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>=0)
10375 {
10376
10377
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10378 {
10379
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10380 {
10381 return qe_invalid;
10382 }
10383
10384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10385 {
10386 return qe_invalid;
10387 }
10388
10389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10390 {
10391 return qe_invalid;
10392 }
10393
10394 144 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10395 144 }
10396
10397
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10398 {
10399
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10400 {
10401 return qe_invalid;
10402 }
10403
10404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10405 {
10406 return qe_invalid;
10407 }
10408
10409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10410 {
10411 return qe_invalid;
10412 }
10413
10414 144 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10415 144 }
10416
10417
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10418 {
10419
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10420 {
10421 return qe_invalid;
10422 }
10423
10424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10425 {
10426 return qe_invalid;
10427 }
10428
10429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10430 {
10431 return qe_invalid;
10432 }
10433
10434 144 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10435 144 }
10436
10437
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10438 {
10439
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10440 {
10441 return qe_invalid;
10442 }
10443
10444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10445 {
10446 return qe_invalid;
10447 }
10448
10449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10450 {
10451 return qe_invalid;
10452 }
10453
10454 144 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10455 144 }
10456
10457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>1)
10458 {
10459
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10460 {
10461
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10462 {
10463 return qe_invalid;
10464 }
10465
10466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10467 {
10468 return qe_invalid;
10469 }
10470
10471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10472 {
10473 return qe_invalid;
10474 }
10475
10476 144 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10477 144 }
10478 36 }
10479
10480
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10481 {
10482
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10483 {
10484 return qe_invalid;
10485 }
10486
10487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10488 {
10489 return qe_invalid;
10490 }
10491
10492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10493 {
10494 return qe_invalid;
10495 }
10496
10497 144 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10498 144 }
10499
10500
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10501 {
10502
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10503 {
10504 return qe_invalid;
10505 }
10506
10507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10508 {
10509 return qe_invalid;
10510 }
10511
10512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10513 {
10514 return qe_invalid;
10515 }
10516
10517 144 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10518 144 }
10519
10520
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tile,f))
10521 {
10522 return qe_invalid;
10523 }
10524
10525 36 flip=0;
10526
10527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>0)
10528 {
10529
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&flip,f))
10530 {
10531 return qe_invalid;
10532 }
10533 36 }
10534
10535
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&extend,f))
10536 {
10537 return qe_invalid;
10538 }
10539
10540 36 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10541
10542
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(v_herosprites>0)
10543 {
10544 36 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10545
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 36 times.
108 for(int32_t i=0; i<2; i++)
10546 {
10547
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 72 times.
288 for(int32_t j=0; j<num_holdsprs; j++)
10548 {
10549
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(!p_igetl(&tile,f))
10550 {
10551 return qe_invalid;
10552 }
10553
10554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&flip,f))
10555 {
10556 return qe_invalid;
10557 }
10558
10559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&extend,f))
10560 {
10561 return qe_invalid;
10562 }
10563
10564 216 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10565 216 }
10566 72 }
10567 36 }
10568 else
10569 {
10570 for(int32_t i=0; i<2; i++)
10571 {
10572 if(!p_igetl(&tile,f))
10573 {
10574 return qe_invalid;
10575 }
10576
10577 if(!p_igetl(&tile2,f))
10578 {
10579 return qe_invalid;
10580 }
10581
10582 if(!p_getc(&extend,f))
10583 {
10584 return qe_invalid;
10585 }
10586
10587 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10588 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10589 }
10590 }
10591
10592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>2)
10593 {
10594
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10595 {
10596
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10597 {
10598 return qe_invalid;
10599 }
10600
10601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10602 {
10603 return qe_invalid;
10604 }
10605
10606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10607 {
10608 return qe_invalid;
10609 }
10610
10611 144 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10612 144 }
10613 36 }
10614
10615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>3)
10616 {
10617
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10618 {
10619
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10620 {
10621 return qe_invalid;
10622 }
10623
10624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10625 {
10626 return qe_invalid;
10627 }
10628
10629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10630 {
10631 return qe_invalid;
10632 }
10633
10634 144 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10635 144 }
10636 36 }
10637
10638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>4)
10639 {
10640
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&dummy_byte,f))
10641 {
10642 return qe_invalid;
10643 }
10644
10645 36 zinit.hero_swim_speed=(byte)dummy_byte;
10646 36 }
10647
10648
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(v_herosprites>6)
10649 {
10650
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10651 {
10652
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10653 return qe_invalid;
10654
10655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10656 return qe_invalid;
10657
10658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10659 return qe_invalid;
10660
10661 144 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10662 144 }
10663
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10664 {
10665
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10666 return qe_invalid;
10667
10668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10669 return qe_invalid;
10670
10671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10672 return qe_invalid;
10673
10674 144 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10675 144 }
10676
10677
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10678 {
10679
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10680 return qe_invalid;
10681
10682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10683 return qe_invalid;
10684
10685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10686 return qe_invalid;
10687
10688 144 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10689 144 }
10690
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10691 {
10692
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10693 return qe_invalid;
10694
10695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10696 return qe_invalid;
10697
10698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10699 return qe_invalid;
10700
10701 144 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10702 144 }
10703
10704
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10705 {
10706
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10707 return qe_invalid;
10708
10709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10710 return qe_invalid;
10711
10712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10713 return qe_invalid;
10714
10715 144 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10716 144 }
10717
10718
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10719 {
10720
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10721 return qe_invalid;
10722
10723
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10724 return qe_invalid;
10725
10726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10727 return qe_invalid;
10728
10729 144 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10730 144 }
10731
10732
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10733 {
10734
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10735 return qe_invalid;
10736
10737
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10738 return qe_invalid;
10739
10740
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10741 return qe_invalid;
10742
10743 144 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10744 144 }
10745
10746
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10747 {
10748
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10749 return qe_invalid;
10750
10751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10752 return qe_invalid;
10753
10754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10755 return qe_invalid;
10756
10757 144 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10758 144 }
10759
10760
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10761 {
10762
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10763 return qe_invalid;
10764
10765
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10766 return qe_invalid;
10767
10768
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10769 return qe_invalid;
10770
10771 144 byte frames = 0;
10772
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 136 times.
144 if(v_herosprites > 15)
10773 {
10774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 if(!p_getc(&frames,f))
10775 return qe_invalid;
10776 136 }
10777
10778 144 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10779 144 liftingspr[q][spr_frames] = frames;
10780 144 }
10781
10782
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10783 {
10784
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10785 return qe_invalid;
10786
10787
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10788 return qe_invalid;
10789
10790
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10791 return qe_invalid;
10792
10793 144 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10794 144 }
10795
10796
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10797 {
10798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&tile,f))
10799 return qe_invalid;
10800
10801
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10802 return qe_invalid;
10803
10804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10805 return qe_invalid;
10806
10807 144 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10808 144 }
10809
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10810 {
10811
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10812 return qe_invalid;
10813
10814
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10815 return qe_invalid;
10816
10817
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10818 return qe_invalid;
10819
10820 144 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10821 144 }
10822
10823
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10824 {
10825
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10826 return qe_invalid;
10827
10828
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10829 return qe_invalid;
10830
10831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10832 return qe_invalid;
10833
10834 144 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10835 144 }
10836
10837
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10838 {
10839
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10840 return qe_invalid;
10841
10842
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10843 return qe_invalid;
10844
10845
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10846 return qe_invalid;
10847
10848 144 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10849 144 }
10850
10851
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10852 {
10853
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10854 return qe_invalid;
10855
10856
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10857 return qe_invalid;
10858
10859
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10860 return qe_invalid;
10861
10862 144 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10863 144 }
10864
10865
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10866 {
10867
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10868 return qe_invalid;
10869
10870
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10871 return qe_invalid;
10872
10873
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10874 return qe_invalid;
10875
10876 144 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10877 144 }
10878
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10879 {
10880
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10881 return qe_invalid;
10882
10883
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10884 return qe_invalid;
10885
10886
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10887 return qe_invalid;
10888
10889 144 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10890 144 }
10891
10892
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10893 {
10894
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10895 return qe_invalid;
10896
10897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10898 return qe_invalid;
10899
10900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10901 return qe_invalid;
10902
10903 144 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10904 144 }
10905
10906
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10907 {
10908
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10909 return qe_invalid;
10910
10911
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10912 return qe_invalid;
10913
10914
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10915 return qe_invalid;
10916
10917 144 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10918 144 }
10919
10920
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10921 {
10922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&tile,f))
10923 return qe_invalid;
10924
10925
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10926 return qe_invalid;
10927
10928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10929 return qe_invalid;
10930
10931 144 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10932 144 }
10933
10934
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10935 {
10936
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10937 return qe_invalid;
10938
10939
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10940 return qe_invalid;
10941
10942
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10943 return qe_invalid;
10944
10945 144 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10946 144 }
10947
10948
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10949 {
10950
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10951 return qe_invalid;
10952
10953
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10954 return qe_invalid;
10955
10956
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10957 return qe_invalid;
10958
10959 144 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10960 144 }
10961
10962
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10963 {
10964
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10965 return qe_invalid;
10966
10967
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10968 return qe_invalid;
10969
10970
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10971 return qe_invalid;
10972
10973 144 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10974 144 }
10975
10976
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 36 times.
144 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10977 {
10978
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_igetl(&tile,f))
10979 return qe_invalid;
10980
10981
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&flip,f))
10982 return qe_invalid;
10983
10984
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&extend,f))
10985 return qe_invalid;
10986
10987 108 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10988 108 }
10989 36 }
10990 else
10991 {
10992 memset(frozenspr, 0, sizeof(frozenspr));
10993 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10994 memset(onfirespr, 0, sizeof(onfirespr));
10995 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10996 memset(diggingspr, 0, sizeof(diggingspr));
10997 memset(usingrodspr, 0, sizeof(usingrodspr));
10998 memset(usingcanespr, 0, sizeof(usingcanespr));
10999 memset(pushingspr, 0, sizeof(pushingspr));
11000 memset(liftingspr, 0, sizeof(liftingspr));
11001 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11002 memset(stunnedspr, 0, sizeof(stunnedspr));
11003 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11004 memset(fallingspr, 0, sizeof(fallingspr));
11005 memset(shockedspr, 0, sizeof(shockedspr));
11006 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11007 memset(pullswordspr, 0, sizeof(pullswordspr));
11008 memset(readingspr, 0, sizeof(readingspr));
11009 memset(slash180spr, 0, sizeof(slash180spr));
11010 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11011 memset(dashspr, 0, sizeof(dashspr));
11012 memset(bonkspr, 0, sizeof(bonkspr));
11013 memset(medallionsprs, 0, sizeof(medallionsprs));
11014 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11015 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11016 for(int32_t q = 0; q < 4; ++q)
11017 {
11018 for(int32_t p = 0; p < 3; ++p)
11019 {
11020 drowningspr[q][p] = divespr[q][p];
11021 drowning_lavaspr[q][p] = divespr[q][p];
11022 }
11023 }
11024 }
11025
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 8)
11026 {
11027
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11028 {
11029
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11030 return qe_invalid;
11031
11032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11033 return qe_invalid;
11034
11035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11036 return qe_invalid;
11037
11038 144 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11039 144 }
11040 36 }
11041 else
11042 {
11043 memset(sideswimspr, 0, sizeof(sideswimspr));
11044 }
11045
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 9)
11046 {
11047
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11048 {
11049
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11050 return qe_invalid;
11051
11052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11053 return qe_invalid;
11054
11055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11056 return qe_invalid;
11057
11058 144 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11059 144 }
11060
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11061 {
11062
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11063 return qe_invalid;
11064
11065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11066 return qe_invalid;
11067
11068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11069 return qe_invalid;
11070
11071 144 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11072 144 }
11073
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11074 {
11075
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11076 return qe_invalid;
11077
11078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11079 return qe_invalid;
11080
11081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11082 return qe_invalid;
11083
11084 144 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11085 144 }
11086
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11087 {
11088
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11089 return qe_invalid;
11090
11091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11092 return qe_invalid;
11093
11094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11095 return qe_invalid;
11096
11097 144 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11098 144 }
11099 36 }
11100 else
11101 {
11102 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11103 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11104 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11105 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11106 }
11107
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 10)
11108 {
11109
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11110 {
11111 int32_t hmr;
11112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&hmr,f))
11113 return qe_invalid;
11114
11115 144 hammeroffsets[q] = hmr;
11116 144 }
11117 36 }
11118 else
11119 {
11120 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11121 }
11122
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 11)
11123 {
11124
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 36 times.
144 for(int32_t q = 0; q < 3; ++q)
11125 {
11126
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_igetl(&tile,f))
11127 return qe_invalid;
11128
11129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!p_getc(&flip,f))
11130 return qe_invalid;
11131
11132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!p_getc(&extend,f))
11133 return qe_invalid;
11134
11135 108 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11136 108 }
11137 36 }
11138 else
11139 {
11140 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11141 }
11142
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 12)
11143 {
11144
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tile,f))
11145 return qe_invalid;
11146
11147
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&flip,f))
11148 return qe_invalid;
11149
11150
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&extend,f))
11151 return qe_invalid;
11152 36 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11153
11154 36 }
11155 else
11156 {
11157 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11158 }
11159
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 13)
11160 {
11161
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11162 {
11163
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11164 return qe_invalid;
11165
11166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11167 return qe_invalid;
11168
11169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11170 return qe_invalid;
11171
11172 144 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11173 144 }
11174 36 }
11175 else
11176 {
11177 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11178 }
11179
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 14)
11180 {
11181
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11182 {
11183
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11184 return qe_invalid;
11185
11186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11187 return qe_invalid;
11188
11189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11190 return qe_invalid;
11191
11192 144 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11193 144 }
11194 36 }
11195 else
11196 {
11197 memset(revslashspr, 0, sizeof(revslashspr));
11198 }
11199
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 7)
11200 {
11201 36 int32_t num_defense = wMax;
11202 36 byte def = 0;
11203
11204 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11205 /*if(v_herosprites > [x])
11206 * {
11207 * num_defense = 146 //value of wMax on version 8
11208 * }
11209 */
11210
11211
2/2
✓ Branch 0 taken 5256 times.
✓ Branch 1 taken 36 times.
5292 for (int32_t q = 0; q < num_defense; q++)
11212 {
11213
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if (!p_getc(&def, f))
11214 return qe_invalid;
11215
11216 5256 hero_defence[q] = def;
11217 5256 }
11218 36 }
11219 else
11220 {
11221 int32_t num_defense = wMax;
11222 for (int32_t q = 0; q < num_defense; q++)
11223 {
11224 hero_defence[q] = 0;
11225 }
11226 }
11227 36 }
11228
11229
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4 times.
36 if(FFCore.quest_format[vInitData] < 34)
11230 {
11231 4 bool fastswim = zinit.hero_swim_speed > 60;
11232 // '2/3' or '1/2'
11233 4 zinit.hero_swim_mult = fastswim ? 2 : 1;
11234 4 zinit.hero_swim_div = fastswim ? 3 : 2;
11235 4 }
11236 36 return 0;
11237 36 }
11238
11239
11240 113 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11241 {
11242 //these are here to bypass compiler warnings about unused arguments
11243 113 Header=Header;
11244
11245 dword dummy;
11246 113 word s_version=0, s_cversion=0;
11247
11248 //section version info
11249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
11250 {
11251 return qe_invalid;
11252 }
11253
11254 113 FFCore.quest_format[vHeroSprites] = s_version;
11255
11256 //al_trace("Player sprites version %d\n", s_version);
11257
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
11258 {
11259 return qe_invalid;
11260 }
11261
11262 //section size
11263
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
11264 {
11265 return qe_invalid;
11266 }
11267
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if ( s_version >= 6 )
11268 {
11269 //al_trace("Reading Player Sprites v6\n");
11270 36 return readherosprites3(f, s_version, dummy);
11271 }
11272 77 else return readherosprites2(f, s_version, dummy);
11273 113 }
11274
11275 85 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11276 {
11277 85 subscreens_active.clear();
11278 85 subscreens_passive.clear();
11279 85 subscreens_overlay.clear();
11280
2/2
✓ Branch 0 taken 10880 times.
✓ Branch 1 taken 85 times.
10965 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11281 {
11282 subscreen_group g;
11283 10880 memset(&g,0,sizeof(subscreen_group));
11284 10880 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10880 times.
10880 if(ret!=0)
11286 return ret;
11287
2/2
✓ Branch 0 taken 393 times.
✓ Branch 1 taken 10487 times.
10880 if(g.objects[0].type == ssoNULL) continue;
11288
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 206 times.
393 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11289 393 ZCSubscreen& sub = vec.emplace_back();
11290 393 sub.load_old(g);
11291 393 }
11292
11293 85 return 0;
11294 85 }
11295
11296 10880 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11297 {
11298 10880 int32_t numsub=0;
11299 10880 byte temp_ss=0;
11300 subscreen_object temp_sub_stack;
11301 10880 subscreen_object *temp_sub = &temp_sub_stack;
11302
11303 char tempname[64];
11304
11305 // FWIW I never saw anything bigger than 20.
11306 #define MAX_DP1_LEN 1024
11307 char tempdp1[MAX_DP1_LEN];
11308
11309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10880 times.
10880 if(!pfread(tempname,64,f))
11310 {
11311 return qe_invalid;
11312 }
11313
11314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10880 times.
10880 if(s_version > 1)
11315 {
11316
1/2
✓ Branch 0 taken 10880 times.
✗ Branch 1 not taken.
10880 if(!p_getc(&temp_ss,f))
11317 {
11318 return qe_invalid;
11319 }
11320 10880 }
11321
11322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10880 times.
10880 if(s_version < 4)
11323 {
11324 uint8_t tmp=0;
11325
11326 if(!p_getc(&tmp,f))
11327 {
11328 return qe_invalid;
11329 }
11330
11331 numsub = (int32_t)tmp;
11332 }
11333 else
11334 {
11335 word tmp;
11336
11337
1/2
✓ Branch 0 taken 10880 times.
✗ Branch 1 not taken.
10880 if(!p_igetw(&tmp, f))
11338 {
11339 return qe_invalid;
11340 }
11341
11342 10880 numsub = (int32_t)tmp;
11343 }
11344
11345 int32_t j;
11346
11347
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24065 times.
✓ Branch 2 taken 13185 times.
✓ Branch 3 taken 10880 times.
24065 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11348 {
11349 13185 memset(temp_sub,0,sizeof(subscreen_object));
11350
11351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13185 times.
13185 switch(g->objects[j].type)
11352 {
11353 case ssoTEXT:
11354 case ssoTEXTBOX:
11355 case ssoCURRENTITEMTEXT:
11356 case ssoCURRENTITEMCLASSTEXT:
11357 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11358
11359 //fall through
11360 default:
11361 13185 memset(&g->objects[j],0,sizeof(subscreen_object));
11362 13185 break;
11363 }
11364
11365
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->type),f))
11366 return qe_invalid;
11367
11368
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->pos),f))
11369 return qe_invalid;
11370
11371
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(s_version < 5)
11372 {
11373 switch(temp_sub->pos)
11374 {
11375 case 0:
11376 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11377 break;
11378
11379 case 1:
11380 temp_sub->pos = sspUP;
11381 break;
11382
11383 case 2:
11384 temp_sub->pos = sspDOWN;
11385 break;
11386
11387 default:
11388 temp_sub->pos = 0;
11389 }
11390 }
11391
11392
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->x),f))
11393 return qe_invalid;
11394
11395
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->y),f))
11396 return qe_invalid;
11397
11398
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->w),f))
11399 return qe_invalid;
11400
11401
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->h),f))
11402 return qe_invalid;
11403
11404
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->colortype1),f))
11405 return qe_invalid;
11406
11407
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->color1),f))
11408 return qe_invalid;
11409
11410
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->colortype2),f))
11411 return qe_invalid;
11412
11413
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->color2),f))
11414 return qe_invalid;
11415
11416
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->colortype3),f))
11417 return qe_invalid;
11418
11419
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->color3),f))
11420 return qe_invalid;
11421
11422
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d1),f))
11423 return qe_invalid;
11424
11425
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d2),f))
11426 return qe_invalid;
11427
11428
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d3),f))
11429 return qe_invalid;
11430
11431
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d4),f))
11432 return qe_invalid;
11433
11434
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d5),f))
11435 return qe_invalid;
11436
11437
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d6),f))
11438 return qe_invalid;
11439
11440
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d7),f))
11441 return qe_invalid;
11442
11443
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d8),f))
11444 return qe_invalid;
11445
11446
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d9),f))
11447 return qe_invalid;
11448
11449
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetd(&(temp_sub->d10),f))
11450 return qe_invalid;
11451
11452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13185 times.
13185 if(s_version < 2)
11453 {
11454 if(!p_igetl(&(temp_sub->speed),f))
11455 return qe_invalid;
11456
11457 if(!p_igetl(&(temp_sub->delay),f))
11458 return qe_invalid;
11459
11460 if(!p_igetl(&(temp_sub->frame),f))
11461 return qe_invalid;
11462 }
11463 else
11464 {
11465
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->speed),f))
11466 return qe_invalid;
11467
11468
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_getc(&(temp_sub->delay),f))
11469 return qe_invalid;
11470
11471
1/2
✓ Branch 0 taken 13185 times.
✗ Branch 1 not taken.
13185 if(!p_igetw(&(temp_sub->frame),f))
11472 return qe_invalid;
11473 }
11474
11475 13185 int32_t temp_size=0;
11476
11477 // bool deletets = false;
11478
4/4
✓ Branch 0 taken 5813 times.
✓ Branch 1 taken 1329 times.
✓ Branch 2 taken 5892 times.
✓ Branch 3 taken 151 times.
13185 switch(temp_sub->type)
11479 {
11480 case ssoTEXT:
11481 case ssoTEXTBOX:
11482 case ssoCURRENTITEMTEXT:
11483 case ssoCURRENTITEMCLASSTEXT:
11484 {
11485 word temptempsize;
11486
11487
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!p_igetw(&temptempsize,f))
11488 {
11489 return qe_invalid;
11490 }
11491
11492 //temptempsize = temp1 + (temp2 << 8);
11493 1329 temp_size = (int32_t)temptempsize;
11494 1329 uint32_t char_length = temp_size+2;
11495
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if (char_length > MAX_DP1_LEN)
11496 {
11497 return qe_invalid;
11498 }
11499 1329 tempdp1[char_length - 1] = '\0';
11500
11501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
1329 if(temp_size)
11502
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!pfread(tempdp1,temp_size+1,f))
11503 return qe_invalid;
11504 1329 break;
11505 }
11506
11507 case ssoLIFEMETER:
11508
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11509 temp_sub->d3 = 1;
11510
11511
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_sub->dp1),f))
11512 return qe_invalid;
11513
11514 151 break;
11515
11516
11517 case ssoCURRENTITEM:
11518
11519
1/2
✓ Branch 0 taken 5813 times.
✗ Branch 1 not taken.
5813 if(s_version < 6)
11520 {
11521 switch(temp_sub->d1)
11522 {
11523 case ssiBOMB:
11524 temp_sub->d1 = itype_bomb;
11525 break;
11526
11527 case ssiSWORD:
11528 temp_sub->d1 = itype_sword;
11529 break;
11530
11531 case ssiSHIELD:
11532 temp_sub->d1 = itype_shield;
11533 break;
11534
11535 case ssiCANDLE:
11536 temp_sub->d1 = itype_candle;
11537 break;
11538
11539 case ssiLETTER:
11540 temp_sub->d1 = itype_letter;
11541 break;
11542
11543 case ssiPOTION:
11544 temp_sub->d1 = itype_potion;
11545 break;
11546
11547 case ssiLETTERPOTION:
11548 temp_sub->d1 = itype_letterpotion;
11549 break;
11550
11551 case ssiBOW:
11552 temp_sub->d1 = itype_bow;
11553 break;
11554
11555 case ssiARROW:
11556 temp_sub->d1 = itype_arrow;
11557 break;
11558
11559 case ssiBOWANDARROW:
11560 temp_sub->d1 = itype_bowandarrow;
11561 break;
11562
11563 case ssiBAIT:
11564 temp_sub->d1 = itype_bait;
11565 break;
11566
11567 case ssiRING:
11568 temp_sub->d1 = itype_ring;
11569 break;
11570
11571 case ssiBRACELET:
11572 temp_sub->d1 = itype_bracelet;
11573 break;
11574
11575 case ssiMAP:
11576 temp_sub->d1 = itype_map;
11577 break;
11578
11579 case ssiCOMPASS:
11580 temp_sub->d1 = itype_compass;
11581 break;
11582
11583 case ssiBOSSKEY:
11584 temp_sub->d1 = itype_bosskey;
11585 break;
11586
11587 case ssiMAGICKEY:
11588 temp_sub->d1 = itype_magickey;
11589 break;
11590
11591 case ssiBRANG:
11592 temp_sub->d1 = itype_brang;
11593 break;
11594
11595 case ssiWAND:
11596 temp_sub->d1 = itype_wand;
11597 break;
11598
11599 case ssiRAFT:
11600 temp_sub->d1 = itype_raft;
11601 break;
11602
11603 case ssiLADDER:
11604 temp_sub->d1 = itype_ladder;
11605 break;
11606
11607 case ssiWHISTLE:
11608 temp_sub->d1 = itype_whistle;
11609 break;
11610
11611 case ssiBOOK:
11612 temp_sub->d1 = itype_book;
11613 break;
11614
11615 case ssiWALLET:
11616 temp_sub->d1 = itype_wallet;
11617 break;
11618
11619 case ssiSBOMB:
11620 temp_sub->d1 = itype_sbomb;
11621 break;
11622
11623 case ssiHCPIECE:
11624 temp_sub->d1 = itype_heartpiece;
11625 break;
11626
11627 case ssiAMULET:
11628 temp_sub->d1 = itype_amulet;
11629 break;
11630
11631 case ssiFLIPPERS:
11632 temp_sub->d1 = itype_flippers;
11633 break;
11634
11635 case ssiHOOKSHOT:
11636 temp_sub->d1 = itype_hookshot;
11637 break;
11638
11639 case ssiLENS:
11640 temp_sub->d1 = itype_lens;
11641 break;
11642
11643 case ssiHAMMER:
11644 temp_sub->d1 = itype_hammer;
11645 break;
11646
11647 case ssiBOOTS:
11648 temp_sub->d1 = itype_boots;
11649 break;
11650
11651 case ssiDIVINEFIRE:
11652 temp_sub->d1 = itype_divinefire;
11653 break;
11654
11655 case ssiDIVINEESCAPE:
11656 temp_sub->d1 = itype_divineescape;
11657 break;
11658
11659 case ssiDIVINEPROTECTION:
11660 temp_sub->d1 = itype_divineprotection;
11661 break;
11662
11663 case ssiQUIVER:
11664 temp_sub->d1 = itype_quiver;
11665 break;
11666
11667 case ssiBOMBBAG:
11668 temp_sub->d1 = itype_bombbag;
11669 break;
11670
11671 case ssiCBYRNA:
11672 temp_sub->d1 = itype_cbyrna;
11673 break;
11674
11675 case ssiROCS:
11676 temp_sub->d1 = itype_rocs;
11677 break;
11678
11679 case ssiHOVERBOOTS:
11680 temp_sub->d1 = itype_hoverboots;
11681 break;
11682
11683 case ssiSPINSCROLL:
11684 temp_sub->d1 = itype_spinscroll;
11685 break;
11686
11687 case ssiCROSSSCROLL:
11688 temp_sub->d1 = itype_crossscroll;
11689 break;
11690
11691 case ssiQUAKESCROLL:
11692 temp_sub->d1 = itype_quakescroll;
11693 break;
11694
11695 case ssiWHISPRING:
11696 temp_sub->d1 = itype_whispring;
11697 break;
11698
11699 case ssiCHARGERING:
11700 temp_sub->d1 = itype_chargering;
11701 break;
11702
11703 case ssiPERILSCROLL:
11704 temp_sub->d1 = itype_perilscroll;
11705 break;
11706
11707 case ssiWEALTHMEDAL:
11708 temp_sub->d1 = itype_wealthmedal;
11709 break;
11710
11711 case ssiHEARTRING:
11712 temp_sub->d1 = itype_heartring;
11713 break;
11714
11715 case ssiMAGICRING:
11716 temp_sub->d1 = itype_magicring;
11717 break;
11718
11719 case ssiSPINSCROLL2:
11720 temp_sub->d1 = itype_spinscroll2;
11721 break;
11722
11723 case ssiQUAKESCROLL2:
11724 temp_sub->d1 = itype_quakescroll2;
11725 break;
11726
11727 case ssiAGONY:
11728 temp_sub->d1 = itype_agony;
11729 break;
11730
11731 case ssiSTOMPBOOTS:
11732 temp_sub->d1 = itype_stompboots;
11733 break;
11734
11735 case ssiWHIMSICALRING:
11736 temp_sub->d1 = itype_whimsicalring;
11737 break;
11738
11739 case ssiPERILRING:
11740 temp_sub->d1 = itype_perilring;
11741 break;
11742
11743 default:
11744 temp_sub->d1 += itype_custom1 - ssiMAX;
11745 }
11746 }
11747
11748 //fall-through
11749 default:
11750
1/2
✓ Branch 0 taken 11705 times.
✗ Branch 1 not taken.
11705 if(!p_getc(&(temp_sub->dp1),f))
11751 return qe_invalid;
11752
11753 11705 break;
11754 }
11755
11756
2/2
✓ Branch 0 taken 4501 times.
✓ Branch 1 taken 8684 times.
13185 if(s_version < 7)
11757 {
11758
3/3
✓ Branch 0 taken 8025 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8684 switch(temp_sub->type)
11759 {
11760 case ssoMAGICGAUGE:
11761 {
11762
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
11763 192 temp_sub->d9 = -1; //-1 now represents 'always'
11764 227 break;
11765 }
11766 case ssoLIFEGAUGE:
11767 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11768 432 break;
11769 }
11770 8684 }
11771
11772
3/3
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 11400 times.
✓ Branch 2 taken 456 times.
13185 switch(temp_sub->type)
11773 {
11774 case ssoTEXT:
11775 case ssoTEXTBOX:
11776 case ssoCURRENTITEMTEXT:
11777 case ssoCURRENTITEMCLASSTEXT:
11778
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1329 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11779
11780 1329 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11781 1329 g->objects[j].dp1 = new char[temp_size+2];
11782 1329 strcpy((char*)g->objects[j].dp1,tempdp1);
11783 1329 break;
11784
11785 case ssoCOUNTER:
11786
1/2
✓ Branch 0 taken 456 times.
✗ Branch 1 not taken.
456 if(s_version<3)
11787 {
11788 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11789 temp_sub->d8=0;
11790 }
11791
11792 default:
11793 11856 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11794 11856 break;
11795 }
11796
11797 13185 g->name[0] = '\0';
11798 13185 strncat(g->name, tempname, 64 - 1);
11799 13185 g->ss_type = temp_ss;
11800 13185 }
11801
11802
2/2
✓ Branch 0 taken 2772095 times.
✓ Branch 1 taken 10880 times.
2782975 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11803 {
11804 //clear all unused object in this subscreen -DD
11805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2772095 times.
2772095 switch(g->objects[j].type)
11806 {
11807 case ssoTEXT:
11808 case ssoTEXTBOX:
11809 case ssoCURRENTITEMTEXT:
11810 case ssoCURRENTITEMCLASSTEXT:
11811 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11812
11813 //fall through
11814 default:
11815 2772095 memset(&g->objects[j],0,sizeof(subscreen_object));
11816 2772095 break;
11817 }
11818 2772095 }
11819
11820 10880 return 0;
11821 10880 }
11822
11823 113 int32_t readsubscreens(PACKFILE *f)
11824 {
11825 word s_version, s_cversion;
11826 dword dummy;
11827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
11828 return qe_invalid;
11829 113 FFCore.quest_format[vSubscreen] = s_version;
11830
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
11831 return qe_invalid;
11832
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f)) //section size
11833 return qe_invalid;
11834
11835
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 28 times.
113 if(s_version < 8)
11836 85 return read_old_subscreens(f,s_version);
11837
11838 28 subscreens_active.clear();
11839 28 subscreens_passive.clear();
11840 28 subscreens_overlay.clear();
11841
11842 byte sz;
11843
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&sz,f))
11844 return qe_invalid;
11845
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 28 times.
116 for(byte q = 0; q < sz; ++q)
11846 {
11847 88 ZCSubscreen& tmp = subscreens_active.emplace_back();
11848
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (auto ret = tmp.read(f, s_version))
11849 return ret;
11850 88 }
11851
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&sz,f))
11852 return qe_invalid;
11853
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 28 times.
140 for(byte q = 0; q < sz; ++q)
11854 {
11855 112 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11856
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if (auto ret = tmp.read(f, s_version))
11857 return ret;
11858 112 }
11859
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&sz,f))
11860 return qe_invalid;
11861
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 28 times.
44 for(byte q = 0; q < sz; ++q)
11862 {
11863 16 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (auto ret = tmp.read(f, s_version))
11865 return ret;
11866 16 }
11867 28 return 0;
11868 113 }
11869
11870 void reset_subscreen(subscreen_group *tempss)
11871 {
11872 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11873 {
11874 switch(tempss->objects[i].type)
11875 {
11876 case ssoTEXT:
11877 case ssoTEXTBOX:
11878 case ssoCURRENTITEMTEXT:
11879 case ssoCURRENTITEMCLASSTEXT:
11880 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11881
11882 //fall through
11883 default:
11884 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11885 break;
11886 }
11887 }
11888 }
11889
11890 31 void reset_subscreens()
11891 {
11892 31 subscreens_active.clear();
11893 31 subscreens_passive.clear();
11894 31 subscreens_overlay.clear();
11895 31 }
11896
11897 31 int32_t setupsubscreens()
11898 {
11899 31 reset_subscreens();
11900 //return 0;
11901
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 62 times.
93 for(int q = 0; q < 2; ++q)
11902 {
11903 62 subscreens_active.emplace_back();
11904 62 subscreens_passive.emplace_back();
11905 62 }
11906 31 int32_t tempsubscreen=zinit.subscreen;
11907
11908
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(tempsubscreen>=ssdtMAX)
11909 tempsubscreen=0;
11910
11911
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 switch(tempsubscreen)
11912 {
11913 case ssdtOLD:
11914 case ssdtNEWSUBSCR:
11915 case ssdtREV2:
11916 case ssdtBSZELDA:
11917 case ssdtBSZELDAMODIFIED:
11918 case ssdtBSZELDAENHANCED:
11919 case ssdtBSZELDACOMPLETE:
11920 {
11921 31 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11922 31 subscreens_active[0].sub_type=sstACTIVE;
11923 31 subscreens_active[0].name = "Active Subscreen (Triforce)";
11924 31 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11925 31 subscreens_active[1].sub_type=sstACTIVE;
11926 31 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11927 31 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11928 31 subscreens_passive[0].sub_type=sstPASSIVE;
11929 31 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11930 31 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11931 31 subscreens_passive[1].sub_type=sstPASSIVE;
11932 31 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11933 31 break;
11934 }
11935
11936 case ssdtZ3:
11937 {
11938 subscreens_active[0].load_old(z3_active_a);
11939 subscreens_active[0].sub_type=sstACTIVE;
11940 subscreens_active[1].load_old(z3_active_ab);
11941 subscreens_active[1].sub_type=sstACTIVE;
11942 subscreens_passive[0].load_old(z3_passive_a);
11943 subscreens_passive[0].sub_type=sstPASSIVE;
11944 subscreens_passive[1].load_old(z3_passive_ab);
11945 subscreens_passive[1].sub_type=sstPASSIVE;
11946 break;
11947 }
11948 }
11949
11950 31 return 0;
11951 }
11952
11953 extern script_data *ffscripts[NUMSCRIPTFFC];
11954 extern script_data *itemscripts[NUMSCRIPTITEM];
11955 extern script_data *guyscripts[NUMSCRIPTGUYS];
11956 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
11957 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11958 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11959 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11960 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11961 extern script_data *playerscripts[NUMSCRIPTPLAYER];
11962 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11963 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11964 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11965 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11966 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11967 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
11968
11969
11970
11971 103 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11972 {
11973 int32_t dummy;
11974 103 word s_version=0, s_cversion=0, zmeta_version=0;
11975 103 byte numscripts=0;
11976 103 numscripts=numscripts; //to avoid unused variables warnings
11977 int32_t ret;
11978
11979 //section version info
11980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(!p_igetw(&s_version,f))
11981 {
11982 return qe_invalid;
11983 }
11984
11985 103 FFCore.quest_format[vFFScript] = s_version;
11986
11987
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_igetw(&s_cversion,f))
11988 {
11989 return qe_invalid;
11990 }
11991
11992
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 36 times.
103 if(s_version >= 18)
11993 {
11994
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&zmeta_version,f))
11995 {
11996 return qe_invalid;
11997 }
11998 36 }
11999
12000 //al_trace("Scripts version %d\n", s_version);
12001 //section size
12002
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_igetl(&dummy,f))
12003 {
12004 return qe_invalid;
12005 }
12006
12007 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12008 103 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12009 103 temp_ffscript_version = s_version;
12010 //miscQdata *the_misc;
12011
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 77 times.
103 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12012 103 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12013
12014 //finally... section data
12015
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 61 times.
57959 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12016 {
12017 57856 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12018
12019
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if (ret)
12020 {
12021 return qe_invalid;
12022 }
12023 57856 }
12024
12025 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12026 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12027 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12028 * there was a version bump a week before a change that broke stuff.
12029 */
12030
7/8
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 36 times.
61 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12031 {
12032 97 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12033 97 }
12034
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version < 19)
12035 {
12036 77 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12037 77 }
12038
12039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 1)
12040 {
12041
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12042 {
12043 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12044
12045
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12046 {
12047 return qe_invalid;
12048 }
12049 28928 }
12050
12051
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12052 {
12053 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12054
12055
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12056 {
12057 return qe_invalid;
12058 }
12059 28928 }
12060
12061
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12062 {
12063 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12064
12065
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12066 {
12067 return qe_invalid;
12068 }
12069 28928 }
12070
12071
12072
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12073 {
12074 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12075
12076
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12077 {
12078 return qe_invalid;
12079 }
12080 28928 }
12081
12082
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version > 16)
12083 {
12084
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 36 times.
324 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12085 {
12086 288 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12087
12088
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if (ret)
12089 {
12090 return qe_invalid;
12091 }
12092 288 }
12093 36 }
12094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version > 13)
12095 {
12096 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12097 {
12098 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12099
12100 if (ret)
12101 {
12102 return qe_invalid;
12103 }
12104 }
12105
12106 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12107 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12108
12109 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12110 }
12111
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 else if(s_version > 4)
12112 {
12113
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12114 {
12115 308 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12116
12117
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if (ret)
12118 {
12119 return qe_invalid;
12120 }
12121 308 }
12122
12123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12124
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12125
12126
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12127
12128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12129
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12130
12131
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12132
12133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12134
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_F6];
12135
12136
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12137
12138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12139
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12140
12141
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12142 77 }
12143 else
12144 {
12145 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12146 {
12147 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12148
12149 if (ret)
12150 {
12151 return qe_invalid;
12152 }
12153 }
12154
12155 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12156 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12157
12158 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12159
12160 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12161 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12162
12163 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12164
12165 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12166 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12167
12168 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12169
12170 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12171 delete globalscripts[GLOBAL_SCRIPT_F6];
12172
12173 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12174
12175 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12176 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12177
12178 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12179 }
12180
12181
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version > 10) //expanded the number of Player scripts to 5.
12182 {
12183
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 36 times.
216 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12184 {
12185 180 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12186
12187
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (ret)
12188 {
12189 return qe_invalid;
12190 }
12191 180 }
12192 36 }
12193 else
12194 {
12195
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 77 times.
308 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12196 {
12197 231 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12198
12199
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if (ret)
12200 {
12201 return qe_invalid;
12202 }
12203 231 }
12204
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[3] != NULL)
12205
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete playerscripts[3];
12206
12207
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[3] = new script_data();
12208
12209
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[4] != NULL)
12210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 delete playerscripts[4];
12211
12212
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[4] = new script_data();
12213 }
12214
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
113 if(s_version > 8 && s_version < 10)
12215 {
12216
12217 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12218 {
12219 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12220
12221 if (ret)
12222 {
12223 return qe_invalid;
12224 }
12225 }
12226 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12227 {
12228 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12229
12230 if (ret)
12231 {
12232 return qe_invalid;
12233 }
12234 }
12235
12236 }
12237
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >= 10)
12238 {
12239
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12240 {
12241 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12242
12243
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12244 {
12245 return qe_invalid;
12246 }
12247 9216 }
12248
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12249 {
12250 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12251
12252
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12253 {
12254 return qe_invalid;
12255 }
12256 9216 }
12257
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12258 {
12259 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12260
12261
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12262 {
12263 return qe_invalid;
12264 }
12265 9216 }
12266
12267 36 }
12268
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >=12)
12269 {
12270
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12271 {
12272 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12273
12274
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12275 {
12276 return qe_invalid;
12277 }
12278 9216 }
12279 36 }
12280
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >=15)
12281 {
12282
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 36 times.
18468 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12283 {
12284 18432 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12285
12286
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (ret)
12287 {
12288 return qe_invalid;
12289 }
12290 18432 }
12291 36 }
12292
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >19)
12293 {
12294 36 word numgenscripts = NUMSCRIPTSGENERIC;
12295
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&numgenscripts,f))
12296 {
12297 return qe_invalid;
12298 }
12299
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 36 times.
18468 for(int32_t i = 0; i < numgenscripts; i++)
12300 {
12301 18432 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12302
12303
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (ret)
12304 {
12305 return qe_invalid;
12306 }
12307 18432 }
12308 36 }
12309
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 8 times.
113 if(s_version >21)
12310 {
12311 8 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12312
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&numsubscripts,f))
12313 {
12314 return qe_invalid;
12315 }
12316
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i = 0; i < numsubscripts; i++)
12317 {
12318 2048 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &subscreenscripts[i], zmeta_version);
12319
12320
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if (ret)
12321 {
12322 return qe_invalid;
12323 }
12324 2048 }
12325 8 }
12326 113 }
12327
12328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 2)
12329 {
12330 int32_t bufsize;
12331 113 p_igetl(&bufsize, f);
12332
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
113 if (bufsize < 0 || bufsize > 1024*1024*10)
12333 {
12334 // God help anyone storing more than 10MB of code in the script buffer.
12335 return qe_invalid;
12336 }
12337 113 char * buf = new char[bufsize+1];
12338 113 pfread(buf, bufsize, f);
12339 113 buf[bufsize]=0;
12340
12341
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 zScript = string(buf);
12342
12343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 delete[] buf;
12344 word numffcbindings;
12345 113 p_igetw(&numffcbindings, f);
12346
12347
2/2
✓ Branch 0 taken 1504 times.
✓ Branch 1 taken 113 times.
1617 for(int32_t i=0; i<numffcbindings; i++)
12348 {
12349 word id;
12350 1504 p_igetw(&id, f);
12351 1504 p_igetl(&bufsize, f);
12352
2/4
✓ Branch 0 taken 1504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1504 times.
1504 if (bufsize < 0 || bufsize > 1024)
12353 return qe_invalid;
12354 1504 buf = new char[bufsize+1];
12355 1504 pfread(buf, bufsize, f);
12356 1504 buf[bufsize]=0;
12357
12358 //fix for buggy older saved quests -DD
12359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1504 times.
1504 if(id < NUMSCRIPTFFC-1)
12360 1504 ffcmap[id].scriptname = buf;
12361
12362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1504 times.
1504 delete[] buf;
12363 1504 }
12364
12365 word numglobalbindings;
12366 113 p_igetw(&numglobalbindings, f);
12367
12368
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 113 times.
547 for(int32_t i=0; i<numglobalbindings; i++)
12369 {
12370 word id;
12371 434 p_igetw(&id, f);
12372 434 p_igetl(&bufsize, f);
12373
2/4
✓ Branch 0 taken 434 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 434 times.
434 if (bufsize < 0 || bufsize > 1024)
12374 return qe_invalid;
12375 434 buf = new char[bufsize+1];
12376 434 pfread(buf, bufsize, f);
12377 434 buf[bufsize]=0;
12378
12379 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12380 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12381 // Ignore these. -DD
12382
3/4
✓ Branch 0 taken 434 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 275 times.
434 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12383 {
12384 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12385
1/2
✓ Branch 0 taken 275 times.
✗ Branch 1 not taken.
275 if(strcmp(buf,"~Continue") == 0)
12386 {
12387 globalmap[id].scriptname = "";
12388
12389 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12390 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12391 }
12392 else
12393 {
12394 275 globalmap[id].scriptname = buf;
12395 }
12396 275 }
12397
12398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 delete[] buf;
12399 434 }
12400
12401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 3)
12402 {
12403 word numitembindings;
12404 113 p_igetw(&numitembindings, f);
12405
12406
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 113 times.
205 for(int32_t i=0; i<numitembindings; i++)
12407 {
12408 word id;
12409 92 p_igetw(&id, f);
12410 92 p_igetl(&bufsize, f);
12411
2/4
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
92 if (bufsize < 0 || bufsize > 1024)
12412 return qe_invalid;
12413 92 buf = new char[bufsize+1];
12414 92 pfread(buf, bufsize, f);
12415 92 buf[bufsize]=0;
12416
12417 //fix this too
12418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(id <NUMSCRIPTITEM-1)
12419 92 itemmap[id].scriptname = buf;
12420
12421
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 delete[] buf;
12422 92 }
12423 113 }
12424 //(v9+)
12425
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 8)
12426 {
12427 //npc scripts
12428 word numnpcbindings;
12429 36 p_igetw(&numnpcbindings, f);
12430
12431
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 36 times.
40 for(int32_t i=0; i<numnpcbindings; i++)
12432 {
12433 word id;
12434 4 p_igetw(&id, f);
12435 4 p_igetl(&bufsize, f);
12436
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if (bufsize < 0 || bufsize > 1024)
12437 return qe_invalid;
12438 4 buf = new char[bufsize+1];
12439 4 pfread(buf, bufsize, f);
12440 4 buf[bufsize]=0;
12441
12442 //fix this too
12443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(id <NUMSCRIPTGUYS-1)
12444 4 npcmap[id].scriptname = buf;
12445
12446
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 delete[] buf;
12447 4 }
12448 //lweapon
12449 word numlwpnbindings;
12450 36 p_igetw(&numlwpnbindings, f);
12451
12452
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 36 times.
69 for(int32_t i=0; i<numlwpnbindings; i++)
12453 {
12454 word id;
12455 33 p_igetw(&id, f);
12456 33 p_igetl(&bufsize, f);
12457
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if (bufsize < 0 || bufsize > 1024)
12458 return qe_invalid;
12459 33 buf = new char[bufsize+1];
12460 33 pfread(buf, bufsize, f);
12461 33 buf[bufsize]=0;
12462
12463 //fix this too
12464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(id <NUMSCRIPTWEAPONS-1)
12465 33 lwpnmap[id].scriptname = buf;
12466
12467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 delete[] buf;
12468 33 }
12469 //eweapon
12470 word numewpnbindings;
12471 36 p_igetw(&numewpnbindings, f);
12472
12473
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 36 times.
91 for(int32_t i=0; i<numewpnbindings; i++)
12474 {
12475 word id;
12476 55 p_igetw(&id, f);
12477 55 p_igetl(&bufsize, f);
12478
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
55 if (bufsize < 0 || bufsize > 1024)
12479 return qe_invalid;
12480 55 buf = new char[bufsize+1];
12481 55 pfread(buf, bufsize, f);
12482 55 buf[bufsize]=0;
12483
12484 //fix this too
12485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(id <NUMSCRIPTWEAPONS-1)
12486 55 ewpnmap[id].scriptname = buf;
12487
12488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 delete[] buf;
12489 55 }
12490 //hero
12491 word numherobindings;
12492 36 p_igetw(&numherobindings, f);
12493
12494
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 36 times.
38 for(int32_t i=0; i<numherobindings; i++)
12495 {
12496 word id;
12497 2 p_igetw(&id, f);
12498 2 p_igetl(&bufsize, f);
12499
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if (bufsize < 0 || bufsize > 1024)
12500 return qe_invalid;
12501 2 buf = new char[bufsize+1];
12502 2 pfread(buf, bufsize, f);
12503 2 buf[bufsize]=0;
12504
12505 //fix this too
12506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(id <NUMSCRIPTPLAYER-1)
12507 2 playermap[id].scriptname = buf;
12508
12509
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 delete[] buf;
12510 2 }
12511 //dmaps
12512 word numdmapbindings;
12513 36 p_igetw(&numdmapbindings, f);
12514
12515
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 36 times.
65 for(int32_t i=0; i<numdmapbindings; i++)
12516 {
12517 word id;
12518 29 p_igetw(&id, f);
12519 29 p_igetl(&bufsize, f);
12520
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
29 if (bufsize < 0 || bufsize > 1024)
12521 return qe_invalid;
12522 29 buf = new char[bufsize+1];
12523 29 pfread(buf, bufsize, f);
12524 29 buf[bufsize]=0;
12525
12526 //fix this too
12527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(id <NUMSCRIPTSDMAP-1)
12528 29 dmapmap[id].scriptname = buf;
12529
12530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 delete[] buf;
12531 29 }
12532 //screen
12533 word numscreenbindings;
12534 36 p_igetw(&numscreenbindings, f);
12535
12536
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 36 times.
72 for(int32_t i=0; i<numscreenbindings; i++)
12537 {
12538 word id;
12539 36 p_igetw(&id, f);
12540 36 p_igetl(&bufsize, f);
12541
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if (bufsize < 0 || bufsize > 1024)
12542 return qe_invalid;
12543 36 buf = new char[bufsize+1];
12544 36 pfread(buf, bufsize, f);
12545 36 buf[bufsize]=0;
12546
12547 //fix this too
12548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(id <NUMSCRIPTSDMAP-1)
12549 36 screenmap[id].scriptname = buf;
12550
12551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 delete[] buf;
12552 36 }
12553 36 }
12554
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 11)
12555 {
12556 word numspritebindings;
12557 36 p_igetw(&numspritebindings, f);
12558
12559
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 36 times.
45 for(int32_t i=0; i<numspritebindings; i++)
12560 {
12561 word id;
12562 9 p_igetw(&id, f);
12563 9 p_igetl(&bufsize, f);
12564
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
9 if (bufsize < 0 || bufsize > 1024)
12565 return qe_invalid;
12566 9 buf = new char[bufsize+1];
12567 9 pfread(buf, bufsize, f);
12568 9 buf[bufsize]=0;
12569
12570 //fix this too
12571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(id <NUMSCRIPTSDMAP-1)
12572 9 itemspritemap[id].scriptname = buf;
12573
12574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 delete[] buf;
12575 9 }
12576 36 }
12577
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >= 15)
12578 {
12579 word numcombobindings;
12580 36 p_igetw(&numcombobindings, f);
12581
12582
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 36 times.
59 for(int32_t i=0; i<numcombobindings; i++)
12583 {
12584 word id;
12585 23 p_igetw(&id, f);
12586 23 p_igetl(&bufsize, f);
12587
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if (bufsize < 0 || bufsize > 1024)
12588 return qe_invalid;
12589 23 buf = new char[bufsize+1];
12590 23 pfread(buf, bufsize, f);
12591 23 buf[bufsize]=0;
12592
12593 //fix this too
12594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTSCOMBODATA-1)
12595 23 comboscriptmap[id].scriptname = buf;
12596
12597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 delete[] buf;
12598 23 }
12599 36 }
12600
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 19)
12601 {
12602 word numgenericbindings;
12603 36 p_igetw(&numgenericbindings, f);
12604
12605
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
48 for(int32_t i=0; i<numgenericbindings; i++)
12606 {
12607 word id;
12608 12 p_igetw(&id, f);
12609 12 p_igetl(&bufsize, f);
12610
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if (bufsize < 0 || bufsize > 1024)
12611 return qe_invalid;
12612 12 buf = new char[bufsize+1];
12613 12 pfread(buf, bufsize, f);
12614 12 buf[bufsize]=0;
12615
12616 //fix this too
12617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(id <NUMSCRIPTSGENERIC-1)
12618 12 genericmap[id].scriptname = buf;
12619
12620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12621 12 }
12622 36 }
12623
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 8 times.
113 if(s_version > 21)
12624 {
12625 word numsubscreenbindings;
12626 8 p_igetw(&numsubscreenbindings, f);
12627
12628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 for(int32_t i=0; i<numsubscreenbindings; i++)
12629 {
12630 word id;
12631 p_igetw(&id, f);
12632 p_igetl(&bufsize, f);
12633 if (bufsize < 0 || bufsize > 1024)
12634 return qe_invalid;
12635 buf = new char[bufsize+1];
12636 pfread(buf, bufsize, f);
12637 buf[bufsize]=0;
12638
12639 //fix this too
12640 if(id <NUMSCRIPTSSUBSCREEN-1)
12641 subscreenmap[id].scriptname = buf;
12642
12643 delete[] buf;
12644 }
12645 8 }
12646 113 }
12647
12648 113 return 0;
12649 113 }
12650
12651 129 void reset_scripts()
12652 {
12653 #ifdef IS_PLAYER
12654 // We can't modify the script data while jit threads are possibly compiling them.
12655 void jit_shutdown();
12656 129 jit_shutdown();
12657 #endif
12658
12659 129 next_script_data_debug_id = 0;
12660
12661
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12662 {
12663
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 58880 times.
66048 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12664
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 else genericscripts[i] = new script_data();
12665 66048 }
12666
12667
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12668 {
12669
1/2
✓ Branch 0 taken 66048 times.
✗ Branch 1 not taken.
66048 if(ffscripts[i]!=NULL)
12670 {
12671 66048 ffscripts[i]->disable();
12672 66048 }
12673 else
12674 {
12675 ffscripts[i] = new script_data();
12676 }
12677 66048 }
12678
12679
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12680 {
12681
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(itemscripts[i]!=NULL)
12682 {
12683 33024 itemscripts[i]->disable();
12684 33024 }
12685 else
12686 {
12687 itemscripts[i] = new script_data();
12688 }
12689 33024 }
12690
12691
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12692 {
12693
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(guyscripts[i]!=NULL)
12694 {
12695 33024 guyscripts[i]->disable();
12696 33024 }
12697 else
12698 {
12699 guyscripts[i] = new script_data();
12700 }
12701 33024 }
12702
12703
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12704 {
12705
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(wpnscripts[i]!=NULL)
12706 {
12707 33024 wpnscripts[i]->disable();
12708 33024 }
12709 else
12710 {
12711 wpnscripts[i] = new script_data();
12712 }
12713 33024 }
12714
12715
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12716 {
12717
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(screenscripts[i]!=NULL)
12718 {
12719 33024 screenscripts[i]->disable();
12720 33024 }
12721 else
12722 {
12723 screenscripts[i] = new script_data();
12724 }
12725 33024 }
12726
12727
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 129 times.
1161 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12728 {
12729
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(globalscripts[i]!=NULL)
12730 {
12731 1032 globalscripts[i]->disable();
12732 1032 }
12733 else
12734 {
12735 globalscripts[i] = new script_data();
12736 }
12737 1032 }
12738
12739
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 129 times.
774 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12740 {
12741
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(playerscripts[i]!=NULL)
12742 {
12743 645 playerscripts[i]->disable();
12744 645 }
12745 else
12746 {
12747 playerscripts[i] = new script_data();
12748 }
12749 645 }
12750
12751
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12752 {
12753
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(lwpnscripts[i]!=NULL)
12754 {
12755 33024 lwpnscripts[i]->disable();
12756 33024 }
12757 else
12758 {
12759 lwpnscripts[i] = new script_data();
12760 }
12761 33024 }
12762
12763
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12764 {
12765
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(ewpnscripts[i]!=NULL)
12766 {
12767 33024 ewpnscripts[i]->disable();
12768 33024 }
12769 else
12770 {
12771 ewpnscripts[i] = new script_data();
12772 }
12773 33024 }
12774
12775
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12776 {
12777
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(dmapscripts[i]!=NULL)
12778 {
12779 33024 dmapscripts[i]->disable();
12780 33024 }
12781 else
12782 {
12783 dmapscripts[i] = new script_data();
12784 }
12785 33024 }
12786
12787
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12788 {
12789
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(itemspritescripts[i]!=NULL)
12790 {
12791 33024 itemspritescripts[i]->disable();
12792 33024 }
12793 else
12794 {
12795 itemspritescripts[i] = new script_data();
12796 }
12797 33024 }
12798
12799
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12800 {
12801
1/2
✓ Branch 0 taken 66048 times.
✗ Branch 1 not taken.
66048 if(comboscripts[i]!=NULL)
12802 {
12803 66048 comboscripts[i]->disable();
12804 66048 }
12805 else
12806 {
12807 comboscripts[i] = new script_data();
12808 }
12809 66048 }
12810
12811
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12812 {
12813
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(subscreenscripts[i]!=NULL)
12814 {
12815 33024 subscreenscripts[i]->disable();
12816 33024 }
12817 else
12818 {
12819 subscreenscripts[i] = new script_data();
12820 }
12821 33024 }
12822 129 }
12823
12824 extern script_command command_list[];
12825 250351 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
12826 {
12827 //Please also update loadquest() when modifying this method -DD
12828 250351 char b33[34] = {0};
12829 250351 b33[33] = 0;
12830 250351 ffscript temp_script;
12831 250351 int32_t num_commands=1000;
12832
12833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250351 times.
250351 if(s_version>=2)
12834 {
12835
2/4
✓ Branch 0 taken 250351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250351 times.
✗ Branch 3 not taken.
250351 if(!p_igetl(&num_commands,f))
12836 {
12837 return qe_invalid;
12838 }
12839 250351 }
12840
12841 #ifdef ZC_FUZZ
12842 const int32_t command_limit = 300000;
12843 #else
12844 250351 const int32_t command_limit = 10000000;
12845 #endif
12846
2/4
✓ Branch 0 taken 250351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250351 times.
✗ Branch 3 not taken.
250351 if (num_commands < 0 || num_commands > command_limit)
12847 {
12848 return qe_invalid;
12849 }
12850
12851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250351 times.
250351 if((*script) != NULL)
12852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250351 times.
250351 delete (*script);
12853
2/4
✓ Branch 0 taken 250351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 250351 times.
✗ Branch 3 not taken.
250351 (*script) = new script_data(num_commands);
12854
12855
2/2
✓ Branch 0 taken 131540 times.
✓ Branch 1 taken 118811 times.
250351 if(s_version >= 16)
12856 {
12857
1/2
✓ Branch 0 taken 131540 times.
✗ Branch 1 not taken.
131540 zasm_meta temp_meta;
12858
12859
2/4
✓ Branch 0 taken 131540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131540 times.
✗ Branch 3 not taken.
131540 if(!p_igetw(&(temp_meta.zasm_v),f))
12860 {
12861 return qe_invalid;
12862 }
12863
12864
2/4
✓ Branch 0 taken 131540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131540 times.
✗ Branch 3 not taken.
131540 if(!p_igetw(&(temp_meta.meta_v),f))
12865 {
12866 return qe_invalid;
12867 }
12868
12869
2/4
✓ Branch 0 taken 131540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131540 times.
✗ Branch 3 not taken.
131540 if(!p_igetw(&(temp_meta.ffscript_v),f))
12870 {
12871 return qe_invalid;
12872 }
12873
12874
2/4
✓ Branch 0 taken 131540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131540 times.
✗ Branch 3 not taken.
131540 if(!p_getc(&(temp_meta.script_type),f))
12875 {
12876 return qe_invalid;
12877 }
12878
12879
2/2
✓ Branch 0 taken 1052320 times.
✓ Branch 1 taken 131540 times.
1183860 for(int32_t q = 0; q < 8; ++q)
12880 {
12881
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 994768 times.
1052320 if(zmeta_version < 3)
12882 {
12883
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
12884 {
12885
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f))
12886 {
12887 return qe_invalid;
12888 }
12889 1899216 }
12890
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
12891 57552 }
12892 else
12893 {
12894
2/4
✓ Branch 0 taken 994768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 994768 times.
✗ Branch 3 not taken.
994768 if(!p_getcstr(&temp_meta.run_idens[q],f))
12895 {
12896 return qe_invalid;
12897 }
12898 }
12899 1052320 }
12900
12901
2/2
✓ Branch 0 taken 131540 times.
✓ Branch 1 taken 1052320 times.
1183860 for(int32_t q = 0; q < 8; ++q)
12902 {
12903
2/4
✓ Branch 0 taken 1052320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1052320 times.
✗ Branch 3 not taken.
1052320 if(!p_getc(&(temp_meta.run_types[q]),f))
12904 {
12905 return qe_invalid;
12906 }
12907 1052320 }
12908
12909
2/4
✓ Branch 0 taken 131540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131540 times.
✗ Branch 3 not taken.
131540 if(!p_getc(&(temp_meta.flags),f))
12910 {
12911 return qe_invalid;
12912 }
12913
12914
2/4
✓ Branch 0 taken 131540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131540 times.
✗ Branch 3 not taken.
131540 if(!p_igetw(&(temp_meta.compiler_v1),f))
12915 {
12916 return qe_invalid;
12917 }
12918
12919
2/4
✓ Branch 0 taken 131540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131540 times.
✗ Branch 3 not taken.
131540 if(!p_igetw(&(temp_meta.compiler_v2),f))
12920 {
12921 return qe_invalid;
12922 }
12923
12924
2/4
✓ Branch 0 taken 131540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131540 times.
✗ Branch 3 not taken.
131540 if(!p_igetw(&(temp_meta.compiler_v3),f))
12925 {
12926 return qe_invalid;
12927 }
12928
12929
2/4
✓ Branch 0 taken 131540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131540 times.
✗ Branch 3 not taken.
131540 if(!p_igetw(&(temp_meta.compiler_v4),f))
12930 {
12931 return qe_invalid;
12932 }
12933
12934
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 124346 times.
131540 if(zmeta_version == 2)
12935 {
12936
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12937 {
12938
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12939 {
12940 return qe_invalid;
12941 }
12942 237402 }
12943
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
12944
12945
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12946 {
12947
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12948 {
12949 return qe_invalid;
12950 }
12951 237402 }
12952
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
12953 7194 }
12954
1/2
✓ Branch 0 taken 124346 times.
✗ Branch 1 not taken.
124346 else if(zmeta_version > 2)
12955 {
12956
2/4
✓ Branch 0 taken 124346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124346 times.
✗ Branch 3 not taken.
124346 if(!p_getcstr(&temp_meta.script_name,f))
12957 return qe_invalid;
12958
2/4
✓ Branch 0 taken 124346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124346 times.
✗ Branch 3 not taken.
124346 if(!p_getcstr(&temp_meta.author,f))
12959 return qe_invalid;
12960 124346 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
12961
2/2
✓ Branch 0 taken 1243460 times.
✓ Branch 1 taken 124346 times.
1367806 for(auto q = 0; q < num_meta_attrib; ++q)
12962 {
12963
2/4
✓ Branch 0 taken 1243460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1243460 times.
✗ Branch 3 not taken.
1243460 if(!p_getcstr(&temp_meta.attributes[q],f))
12964 return qe_invalid;
12965
2/4
✓ Branch 0 taken 1243460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1243460 times.
✗ Branch 3 not taken.
1243460 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12966 return qe_invalid;
12967 1243460 }
12968
2/2
✓ Branch 0 taken 994768 times.
✓ Branch 1 taken 124346 times.
1119114 for(auto q = 0; q < 8; ++q)
12969 {
12970
2/4
✓ Branch 0 taken 994768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 994768 times.
✗ Branch 3 not taken.
994768 if(!p_getcstr(&temp_meta.attribytes[q],f))
12971 return qe_invalid;
12972
2/4
✓ Branch 0 taken 994768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 994768 times.
✗ Branch 3 not taken.
994768 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12973 return qe_invalid;
12974 994768 }
12975
2/2
✓ Branch 0 taken 994768 times.
✓ Branch 1 taken 124346 times.
1119114 for(auto q = 0; q < 8; ++q)
12976 {
12977
2/4
✓ Branch 0 taken 994768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 994768 times.
✗ Branch 3 not taken.
994768 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12978 return qe_invalid;
12979
2/4
✓ Branch 0 taken 994768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 994768 times.
✗ Branch 3 not taken.
994768 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12980 return qe_invalid;
12981 994768 }
12982
2/2
✓ Branch 0 taken 1989536 times.
✓ Branch 1 taken 124346 times.
2113882 for(auto q = 0; q < 16; ++q)
12983 {
12984
2/4
✓ Branch 0 taken 1989536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1989536 times.
✗ Branch 3 not taken.
1989536 if(!p_getcstr(&temp_meta.usrflags[q],f))
12985 return qe_invalid;
12986
2/4
✓ Branch 0 taken 1989536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1989536 times.
✗ Branch 3 not taken.
1989536 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12987 return qe_invalid;
12988 1989536 }
12989 124346 }
12990
2/2
✓ Branch 0 taken 124346 times.
✓ Branch 1 taken 7194 times.
131540 if(zmeta_version > 3)
12991 {
12992
2/2
✓ Branch 0 taken 994768 times.
✓ Branch 1 taken 124346 times.
1119114 for(auto q = 0; q < 8; ++q)
12993 {
12994
2/4
✓ Branch 0 taken 994768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 994768 times.
✗ Branch 3 not taken.
994768 if(!p_getcstr(&temp_meta.initd[q],f))
12995 return qe_invalid;
12996
2/4
✓ Branch 0 taken 994768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 994768 times.
✗ Branch 3 not taken.
994768 if(!p_getwstr(&temp_meta.initd_help[q],f))
12997 return qe_invalid;
12998 994768 }
12999
2/2
✓ Branch 0 taken 994768 times.
✓ Branch 1 taken 124346 times.
1119114 for(auto q = 0; q < 8; ++q)
13000 {
13001
2/4
✓ Branch 0 taken 994768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 994768 times.
✗ Branch 3 not taken.
994768 if(!p_getc(&temp_meta.initd_type[q],f))
13002 return qe_invalid;
13003 994768 }
13004 124346 }
13005 else
13006 {
13007
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13008 {
13009
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13010 57552 }
13011 }
13012
13013
1/2
✓ Branch 0 taken 131540 times.
✗ Branch 1 not taken.
131540 (*script)->meta = temp_meta;
13014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131540 times.
131540 }
13015
13016
1/2
✓ Branch 0 taken 250351 times.
✗ Branch 1 not taken.
250351 temp_script.clear();
13017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21659745 times.
21659745 for(int32_t j=0; j<num_commands; j++)
13018 {
13019
2/4
✓ Branch 0 taken 21659745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21659745 times.
✗ Branch 3 not taken.
21659745 if(!p_igetw(&(temp_script.command),f))
13020 {
13021 return qe_invalid;
13022 }
13023
13024
2/2
✓ Branch 0 taken 250351 times.
✓ Branch 1 taken 21409394 times.
21659745 if(temp_script.command == 0xFFFF)
13025 {
13026
1/2
✓ Branch 0 taken 250351 times.
✗ Branch 1 not taken.
250351 (*script)->zasm[j].clear();
13027 250351 break;
13028 }
13029 else
13030 {
13031
2/4
✓ Branch 0 taken 21409394 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21409394 times.
✗ Branch 3 not taken.
21409394 if(!p_igetl(&(temp_script.arg1),f))
13032 {
13033 return qe_invalid;
13034 }
13035
13036
2/4
✓ Branch 0 taken 21409394 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21409394 times.
✗ Branch 3 not taken.
21409394 if(!p_igetl(&(temp_script.arg2),f))
13037 {
13038 return qe_invalid;
13039 }
13040
13041
2/2
✓ Branch 0 taken 736773 times.
✓ Branch 1 taken 20672621 times.
21409394 if(s_version >= 21)
13042 {
13043 736773 uint32_t sz = 0;
13044
2/4
✓ Branch 0 taken 736773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 736773 times.
✗ Branch 3 not taken.
736773 if(!p_igetl(&sz,f))
13045 {
13046 return qe_invalid;
13047 }
13048
2/2
✓ Branch 0 taken 3103 times.
✓ Branch 1 taken 733670 times.
736773 if(sz) //string found
13049 {
13050
1/2
✓ Branch 0 taken 3103 times.
✗ Branch 1 not taken.
3103 temp_script.strptr = new std::string();
13051 char dummy;
13052
2/2
✓ Branch 0 taken 229672 times.
✓ Branch 1 taken 3103 times.
232775 for(size_t q = 0; q < sz; ++q)
13053 {
13054
2/4
✓ Branch 0 taken 229672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229672 times.
✗ Branch 3 not taken.
229672 if(!p_getc(&dummy,f))
13055 {
13056 return qe_invalid;
13057 }
13058
1/2
✓ Branch 0 taken 229672 times.
✗ Branch 1 not taken.
229672 temp_script.strptr->push_back(dummy);
13059 229672 }
13060 3103 }
13061
2/4
✓ Branch 0 taken 736773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 736773 times.
✗ Branch 3 not taken.
736773 if(!p_igetl(&sz,f))
13062 {
13063 return qe_invalid;
13064 }
13065
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 736751 times.
736773 if(sz) //vector found
13066 {
13067
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 temp_script.vecptr = new std::vector<int32_t>();
13068 int32_t dummy;
13069
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 22 times.
374 for(size_t q = 0; q < sz; ++q)
13070 {
13071
2/4
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 352 times.
✗ Branch 3 not taken.
352 if(!p_igetl(&dummy,f))
13072 {
13073 return qe_invalid;
13074 }
13075
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 temp_script.vecptr->push_back(dummy);
13076 352 }
13077 22 }
13078 736773 }
13079
13080
1/2
✓ Branch 0 taken 21409394 times.
✗ Branch 1 not taken.
21409394 temp_script.give((*script)->zasm[j]);
13081 }
13082
1/2
✓ Branch 0 taken 21409394 times.
✗ Branch 1 not taken.
21409394 temp_script.clear();
13083 21409394 }
13084
13085 250351 return 0;
13086 250351 }
13087
13088 extern SAMPLE customsfxdata[WAV_COUNT];
13089 extern uint8_t customsfxflag[WAV_COUNT>>3];
13090 extern int32_t sfxdat;
13091 extern DATAFILE *sfxdata;
13092 const char *old_sfx_string[Z35] =
13093 {
13094 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13095 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13096 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13097 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13098 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13099 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13100 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13101 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13102 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13103 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13104 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13105 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13106 };
13107 char *sfx_string[WAV_COUNT];
13108
13109 113 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13110 {
13111 //these are here to bypass compiler warnings about unused arguments
13112 113 Header=Header;
13113
13114 int32_t dummy;
13115 113 word s_version=0, s_cversion=0;
13116 //int32_t ret;
13117 SAMPLE temp_sample;
13118 113 temp_sample.loop_start=0;
13119 113 temp_sample.loop_end=0;
13120 113 temp_sample.param=0;
13121
13122 //section version info
13123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
13124 {
13125 return qe_invalid;
13126 }
13127
13128 113 FFCore.quest_format[vSFX] = s_version;
13129
13130 //al_trace("SFX version %d\n", s_version);
13131
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
13132 {
13133 return qe_invalid;
13134 }
13135
13136 //section size
13137
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
13138 {
13139 return qe_invalid;
13140 }
13141
13142 /* HIGHLY UNORTHODOX UPDATING THING, by L
13143 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13144 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13145 * changing from 1 to 2.
13146 */
13147
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 2)
13148 set_qr(qr_GOTOLESSNOTEQUAL,1);
13149
13150 /* End highly unorthodox updating thing */
13151
13152 113 int32_t wavcount = WAV_COUNT;
13153
13154
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 6)
13155 wavcount = 128;
13156
13157 uint8_t tempflag[WAV_COUNT>>3];
13158
13159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version < 4)
13160 {
13161 memset(tempflag, 0xFF, WAV_COUNT>>3);
13162 }
13163 else
13164 {
13165
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 6)
13166 memset(tempflag, 0, WAV_COUNT>>3);
13167
13168
2/2
✓ Branch 0 taken 3616 times.
✓ Branch 1 taken 113 times.
3729 for(int32_t i=0; i<(wavcount>>3); i++)
13169 {
13170 3616 p_getc(&tempflag[i], f);
13171 3616 }
13172
13173 }
13174
13175
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version>4)
13176 {
13177
2/2
✓ Branch 0 taken 28815 times.
✓ Branch 1 taken 113 times.
28928 for(int32_t i=1; i<WAV_COUNT; i++)
13178 {
13179 28815 sprintf(sfx_string[i],"s%03d",i);
13180
13181
2/2
✓ Branch 0 taken 22035 times.
✓ Branch 1 taken 6780 times.
28815 if((i<Z35))
13182 6780 strcpy(sfx_string[i], old_sfx_string[i-1]);
13183
13184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28815 times.
28815 if(i>=wavcount)
13185 continue;
13186
2/2
✓ Branch 0 taken 2993 times.
✓ Branch 1 taken 25822 times.
28815 if(get_bit(tempflag, i-1))
13187 {
13188 char tempname[36];
13189
13190
1/2
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
2993 if(!pfread(tempname, 36, f))
13191 {
13192 return qe_invalid;
13193 }
13194
13195 2993 sfx_string[i][0] = '\0';
13196 2993 strncat(sfx_string[i], tempname, 36 - 1);
13197 2993 }
13198 else
13199 {
13200 25822 sprintf(sfx_string[i],"s%03d",i);
13201
13202
2/2
✓ Branch 0 taken 21244 times.
✓ Branch 1 taken 4578 times.
25822 if(i<Z35)
13203 4578 strcpy(sfx_string[i], old_sfx_string[i-1]);
13204 25822 sfx_string[i][35] = 0; //Force NULL Termination
13205 }
13206 28815 }
13207 113 }
13208 else
13209 {
13210 for(int32_t i=1; i<WAV_COUNT; i++)
13211 {
13212 sprintf(sfx_string[i],"s%03d",i);
13213
13214 if(i<Z35)
13215 strcpy(sfx_string[i], old_sfx_string[i-1]);
13216 }
13217 }
13218
13219 //finally... section data
13220
2/2
✓ Branch 0 taken 28815 times.
✓ Branch 1 taken 113 times.
28928 for(int32_t i=1; i<wavcount; i++)
13221 {
13222
2/2
✓ Branch 0 taken 2993 times.
✓ Branch 1 taken 25822 times.
28815 if(get_bit(tempflag, i-1))
13223 {
13224
13225
1/2
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
2993 if(!p_igetl(&dummy,f))
13226 {
13227 return qe_invalid;
13228 }
13229
13230 2993 (temp_sample.bits) = dummy;
13231
13232
1/2
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
2993 if(!p_igetl(&dummy,f))
13233 {
13234 return qe_invalid;
13235 }
13236
13237 2993 (temp_sample.stereo) = dummy;
13238
13239
1/2
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
2993 if(!p_igetl(&dummy,f))
13240 {
13241 return qe_invalid;
13242 }
13243
13244 2993 (temp_sample.freq) = dummy;
13245
13246
1/2
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
2993 if(!p_igetl(&dummy,f))
13247 {
13248 return qe_invalid;
13249 }
13250
13251 2993 (temp_sample.priority) = dummy;
13252
13253
1/2
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
2993 if(!p_igetl(&(temp_sample.len),f))
13254 {
13255 return qe_invalid;
13256 }
13257
13258
1/2
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
2993 if(!p_igetl(&(temp_sample.loop_start),f))
13259 {
13260 return qe_invalid;
13261 }
13262
13263
1/2
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
2993 if(!p_igetl(&(temp_sample.loop_end),f))
13264 {
13265 return qe_invalid;
13266 }
13267
13268
1/2
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
2993 if(!p_igetl(&(temp_sample.param),f))
13269 {
13270 return qe_invalid;
13271 }
13272
13273 // al_trace("F%i: L%i\n",i,temp_sample.len);
13274 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13275 2993 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13276
2/4
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2993 times.
2993 if (len < 0 || len > 10000000)
13277 {
13278 return qe_invalid;
13279 }
13280 2993 temp_sample.data = calloc(len,1);
13281
13282
1/2
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
2993 if(s_version < 3)
13283 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13284
13285 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2993 times.
2993 if(s_version < 2)
13287 {
13288 if(!pfread(temp_sample.data, len,f))
13289 {
13290 return qe_invalid;
13291 }
13292 }
13293 else
13294 {
13295 //re-endianfy the data
13296 2993 int32_t wordstoread = len / sizeof(word);
13297
13298
2/2
✓ Branch 0 taken 84992885 times.
✓ Branch 1 taken 2993 times.
84995878 for(int32_t j=0; j<wordstoread; j++)
13299 {
13300 word temp;
13301
13302
1/2
✓ Branch 0 taken 84992885 times.
✗ Branch 1 not taken.
84992885 if(!p_igetw(&temp, f))
13303 {
13304 return qe_invalid;
13305 }
13306
13307 84992885 ((word *)temp_sample.data)[j] = temp;
13308 84992885 }
13309 }
13310 2993 }
13311
2/2
✓ Branch 0 taken 4578 times.
✓ Branch 1 taken 21244 times.
25822 else if(i < Z35)
13312 {
13313 4578 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13314 4578 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13315 4578 set_bit(tempflag, i-1, 1);
13316 4578 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13317 4578 temp_sample.data = calloc(len,1);
13318 4578 memcpy(temp_sample.data, datsamp->data, len);
13319 4578 }
13320 21244 else continue;
13321
13322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7571 times.
7571 if(customsfxdata[i].data!=NULL)
13323 {
13324 // delete [] customsfxdata[i].data;
13325 7571 free(customsfxdata[i].data);
13326 7571 }
13327
13328 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13329 7571 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13330 7571 customsfxdata[i].data = calloc(len2,1);
13331 7571 customsfxdata[i].bits = temp_sample.bits;
13332 7571 customsfxdata[i].stereo = temp_sample.stereo;
13333 7571 customsfxdata[i].freq = temp_sample.freq;
13334 7571 customsfxdata[i].priority = temp_sample.priority;
13335 7571 customsfxdata[i].len = temp_sample.len;
13336 7571 customsfxdata[i].loop_start = temp_sample.loop_start;
13337 7571 customsfxdata[i].loop_end = temp_sample.loop_end;
13338 7571 customsfxdata[i].param = temp_sample.param;
13339 7571 int32_t cpylen = len2;
13340
13341
1/2
✓ Branch 0 taken 7571 times.
✗ Branch 1 not taken.
7571 if(s_version<3)
13342 {
13343 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13344 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13345 }
13346
13347 7571 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13348
13349 7571 free(temp_sample.data);
13350 7571 }
13351
13352 113 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13353
13354 113 sfxdat=0;
13355 113 return 0;
13356 113 }
13357
13358 129 void setupsfx()
13359 {
13360
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=1; i<WAV_COUNT; i++)
13361 {
13362 32895 sprintf(sfx_string[i],"s%03d",i);
13363
13364
2/2
✓ Branch 0 taken 25155 times.
✓ Branch 1 taken 7740 times.
32895 if(i<Z35)
13365 {
13366 7740 strcpy(sfx_string[i], old_sfx_string[i-1]);
13367 7740 }
13368
13369 32895 memset(customsfxflag, 0, WAV_COUNT>>3);
13370
13371 32895 int32_t j=i;
13372
13373
2/2
✓ Branch 0 taken 7869 times.
✓ Branch 1 taken 25026 times.
32895 if(i>Z35)
13374 {
13375 25026 i=Z35;
13376 25026 }
13377
13378 32895 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13379
13380
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 3570 times.
32895 if(customsfxdata[j].data!=NULL)
13381 {
13382 // delete [] customsfxdata[j].data;
13383 3570 free(customsfxdata[j].data);
13384 3570 }
13385
13386 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13387 32895 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13388 32895 customsfxdata[j].bits = temp_sample->bits;
13389 32895 customsfxdata[j].stereo = temp_sample->stereo;
13390 32895 customsfxdata[j].freq = temp_sample->freq;
13391 32895 customsfxdata[j].priority = temp_sample->priority;
13392 32895 customsfxdata[j].len = temp_sample->len;
13393 32895 customsfxdata[j].loop_start = temp_sample->loop_start;
13394 32895 customsfxdata[j].loop_end = temp_sample->loop_end;
13395 32895 customsfxdata[j].param = temp_sample->param;
13396 32895 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13397 32895 i=j;
13398 32895 }
13399 129 }
13400
13401 extern char *guy_string[eMAXGUYS];
13402 extern const char *old_guy_string[OLDMAXGUYS];
13403
13404 129 int32_t readguys(PACKFILE *f, zquestheader *Header)
13405 {
13406 dword dummy;
13407 word guy_cversion;
13408 129 word guyversion=0;
13409
13410
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version >= 0x193)
13411 {
13412 //section version info
13413
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&guyversion,f))
13414 {
13415 return qe_invalid;
13416 }
13417
13418 125 FFCore.quest_format[vGuys] = guyversion;
13419
13420 //al_trace("Guys version %d\n", guyversion);
13421
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&guy_cversion,f))
13422 {
13423 return qe_invalid;
13424 }
13425 125 al_trace("Guy CVersion is: %d\n", guy_cversion);
13426 //section size
13427
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
13428 {
13429 return qe_invalid;
13430 }
13431 125 }
13432
13433
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(guyversion > 3)
13434 {
13435
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXGUYS; i++)
13436 {
13437 char tempname[64];
13438
13439 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13440 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13441
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57856 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13442 {
13443 memset(tempname, 0, sizeof(char)*64);
13444 sprintf(tempname, "e%03d", i);
13445 strcpy(guy_string[i], tempname);
13446
13447 continue;
13448 }
13449
13450
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(tempname, 64, f))
13451 {
13452 return qe_invalid;
13453 }
13454
13455 // Don't retain names of uneditable enemy entries!
13456 // for version upgrade to 2.5
13457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57856 if(guyversion < 23 && i >= 177)
13458 {
13459 // some of the older builds have names such as 'zz123',
13460 // (this order gets messed up with some eXXX and some zzXXX)
13461 // so let's update to the newer naming convection. -Gleeok
13462 char tmpbuf[64];
13463 memset(tmpbuf, 0, sizeof(char)*64);
13464 sprintf(tmpbuf, "zz%03d", i);
13465
13466 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13467 {
13468 memset(tempname, 0, sizeof(char)*64);
13469 sprintf(tempname, "e%03d", i);
13470 }
13471 }
13472
13473
6/6
✓ Branch 0 taken 20001 times.
✓ Branch 1 taken 37855 times.
✓ Branch 2 taken 18984 times.
✓ Branch 3 taken 1017 times.
✓ Branch 4 taken 15955 times.
✓ Branch 5 taken 3029 times.
57856 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13474 {
13475 54827 guy_string[i][0] = '\0';
13476 54827 strncat(guy_string[i], tempname, 64 - 1);
13477 54827 }
13478 else
13479 {
13480 3029 strcpy(guy_string[i],old_guy_string[i]);
13481 }
13482 57856 }
13483 113 }
13484 else
13485 {
13486
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<eMAXGUYS; i++)
13487 {
13488 8192 sprintf(guy_string[i],"zz%03d",i);
13489 8192 }
13490
13491
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 16 times.
2848 for(int32_t i=0; i<OLDMAXGUYS; i++)
13492 {
13493 2832 strcpy(guy_string[i],old_guy_string[i]);
13494 2832 }
13495 }
13496
13497
13498 //finally... section data
13499 129 init_guys(guyversion); //using default data for now...
13500
13501 // Goriya guy fix
13502
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13503 {
13504
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(get_qr(qr_NEWENEMYTILES))
13505 {
13506 12 guysbuf[gGORIYA].tile=130;
13507 12 guysbuf[gGORIYA].e_tile=130;
13508 12 }
13509 16 }
13510
13511
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version < 0x193)
13512 {
13513
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13514 {
13515 guysbuf[eDODONGO].cset=14;
13516 guysbuf[eDODONGO].bosspal=spDIG;
13517 }
13518 4 }
13519 // Not sure when this first changed, but it's necessary for 2.10, at least
13520 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13521 //2.10 Fixes
13522
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13523 {
13524 16 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13525 16 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13526 16 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13527 16 guysbuf[eCENT1].misc3 = 1;
13528 16 guysbuf[eCENT2].misc3 = 1;
13529 16 }
13530
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13531 {
13532 129 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13533 129 }
13534
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(Header->zelda_version <= 0x210)
13535 {
13536 16 guysbuf[eGLEEOK1F].misc6 = 16;
13537 16 guysbuf[eGLEEOK2F].misc6 = 16;
13538 16 guysbuf[eGLEEOK3F].misc6 = 16;
13539 16 guysbuf[eGLEEOK4F].misc6 = 16;
13540
13541 16 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13542 16 guysbuf[eBATROBE].misc4 = 1;
13543 //guysbuf[eSUMMONER].misc4 = 1;
13544 16 guysbuf[eWWIZ].misc4 = 1;
13545 16 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13546 16 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13547 16 }
13548
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version == 0x190)
13549 {
13550 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13551 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13552 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13553 4 }
13554
13555 // The versions here may not be correct
13556 // zelda_version>=0x211 handled at guyversion<24
13557
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version <= 0x190)
13558 {
13559 4 guysbuf[eCENT1].misc3 = 0;
13560 4 guysbuf[eCENT2].misc3 = 0;
13561 4 guysbuf[eMOLDORM].misc2 = 0;
13562 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13563 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13564 4 }
13565
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 else if(Header->zelda_version <= 0x210)
13566 {
13567 12 guysbuf[eCENT1].misc3 = 1;
13568 12 guysbuf[eCENT2].misc3 = 1;
13569 12 guysbuf[eMOLDORM].misc2 = 0;
13570 12 }
13571
13572
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13573 {
13574 16 guysbuf[eKEESE1].misc16 = 120;
13575 16 guysbuf[eKEESE2].misc16 = 120;
13576 16 guysbuf[eKEESE3].misc16 = 120;
13577 16 guysbuf[eKEESETRIB].misc16 = 120;
13578 16 guysbuf[eKEESE1].misc17 = 16;
13579 16 guysbuf[eKEESE2].misc17 = 16;
13580 16 guysbuf[eKEESE3].misc17 = 16;
13581 16 guysbuf[eKEESETRIB].misc17 = 16;
13582
13583 16 guysbuf[ePEAHAT].misc16 = 80;
13584 16 guysbuf[ePEAHAT].misc17 = 16;
13585
13586 16 guysbuf[eGHINI2].misc16 = 120;
13587 16 guysbuf[eGHINI2].misc17 = 10;
13588
13589 16 }
13590
13591
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(guyversion<=2)
13592 {
13593 16 return readherosprites2(f, guyversion==2?0:-1, 0);
13594 }
13595
13596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(guyversion > 3)
13597 {
13598 guydata tempguy;
13599
13600
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXGUYS; i++)
13601 {
13602
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 23) // May 2012 : 512 max enemies
13603 {
13604 if(i >= OLDBETAMAXGUYS)
13605 {
13606 memset(&guysbuf[i], 0, sizeof(guydata));
13607 continue;
13608 }
13609 }
13610
13611 57856 memset(&tempguy, 0, sizeof(guydata));
13612
13613
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.flags),f))
13614 {
13615 return qe_invalid;
13616 }
13617
13618
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.flags2),f))
13619 {
13620 return qe_invalid;
13621 }
13622
13623
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13624 {
13625
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.tile),f))
13626 {
13627 return qe_invalid;
13628 }
13629 18432 }
13630 else
13631 {
13632
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.tile),f))
13633 {
13634 return qe_invalid;
13635 }
13636 }
13637
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.width),f))
13638 {
13639 return qe_invalid;
13640 }
13641
13642
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.height),f))
13643 {
13644 return qe_invalid;
13645 }
13646
13647
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13648 {
13649
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.s_tile),f))
13650 {
13651 return qe_invalid;
13652 }
13653 18432 }
13654 else
13655 {
13656
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.s_tile),f))
13657 {
13658 return qe_invalid;
13659 }
13660 }
13661
13662
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.s_width),f))
13663 {
13664 return qe_invalid;
13665 }
13666
13667
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.s_height),f))
13668 {
13669 return qe_invalid;
13670 }
13671
13672
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13673 {
13674
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.e_tile),f))
13675 {
13676 return qe_invalid;
13677 }
13678 18432 }
13679 else
13680 {
13681
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.e_tile),f))
13682 {
13683 return qe_invalid;
13684 }
13685 }
13686
13687
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.e_width),f))
13688 {
13689 return qe_invalid;
13690 }
13691
13692
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.e_height),f))
13693 {
13694 return qe_invalid;
13695 }
13696
13697
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.hp),f))
13698 {
13699 return qe_invalid;
13700 }
13701
13702
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.family),f))
13703 {
13704 return qe_invalid;
13705 }
13706
13707
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
57856 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13708 {
13709 if(get_qr(qr_NEWENEMYTILES))
13710 {
13711 tempguy.s_tile=tempguy.e_tile+120;
13712 tempguy.s_width=tempguy.e_width;
13713 tempguy.s_height=tempguy.e_height;
13714 }
13715 else tempguy.s_tile=860;
13716 }
13717
13718
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.cset),f))
13719 {
13720 return qe_invalid;
13721 }
13722
13723
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.anim),f))
13724 {
13725 return qe_invalid;
13726 }
13727
13728
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.e_anim),f))
13729 {
13730 return qe_invalid;
13731 }
13732
13733
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.frate),f))
13734 {
13735 return qe_invalid;
13736 }
13737
13738
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.e_frate),f))
13739 {
13740 return qe_invalid;
13741 }
13742
13743
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 13) // April 2009
13744 {
13745 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13746 {
13747 tempguy.frate *= 2;
13748 tempguy.e_frate *= 2;
13749 }
13750 }
13751
13752
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 14) // May 1 2009
13753 {
13754 if(tempguy.anim==a2FRMSLOW)
13755 {
13756 tempguy.anim=a2FRM;
13757 tempguy.frate *= 2;
13758 }
13759
13760 if(tempguy.e_anim==a2FRMSLOW)
13761 {
13762 tempguy.e_anim=a2FRM;
13763 tempguy.e_frate *= 2;
13764 }
13765
13766 if(tempguy.anim==aFLIPSLOW)
13767 {
13768 tempguy.anim=aFLIP;
13769 tempguy.frate *= 2;
13770 }
13771
13772 if(tempguy.e_anim==aFLIPSLOW)
13773 {
13774 tempguy.e_anim=aFLIP;
13775 tempguy.e_frate *= 2;
13776 }
13777
13778 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
13779
13780 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
13781
13782 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
13783 {
13784 tempguy.anim=a4FRM4DIR;
13785 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13786 }
13787
13788 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
13789 {
13790 tempguy.e_anim=a4FRM4DIR;
13791 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13792 }
13793 }
13794
13795
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.dp),f))
13796 {
13797 return qe_invalid;
13798 }
13799
13800 //correction for guy fire
13801
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 6)
13802 {
13803 if(i == gFIRE)
13804 tempguy.dp = 2;
13805 }
13806
13807
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.wdp),f))
13808 {
13809 return qe_invalid;
13810 }
13811
13812
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.weapon),f))
13813 {
13814 return qe_invalid;
13815 }
13816
13817 //correction for bosses using triple, "rising" fireballs
13818
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 5)
13819 {
13820 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
13821 i == eGOHMA3 || i == eGOHMA4)
13822 {
13823 if(tempguy.weapon == ewFireball)
13824 tempguy.weapon = ewFireball2;
13825 }
13826 }
13827
13828
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.rate),f))
13829 {
13830 return qe_invalid;
13831 }
13832
13833
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.hrate),f))
13834 {
13835 return qe_invalid;
13836 }
13837
13838
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.step),f))
13839 {
13840 return qe_invalid;
13841 }
13842
13843 // HIGHLY UNORTHODOX UPDATING THING, part 2
13844
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 56320 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
57856 if(fixpolsvoice && tempguy.family==eePOLSV)
13845 {
13846 tempguy.step /= 2;
13847 }
13848
13849
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.homing),f))
13850 {
13851 return qe_invalid;
13852 }
13853
13854
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.grumble),f))
13855 {
13856 return qe_invalid;
13857 }
13858
13859
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.item_set),f))
13860 {
13861 return qe_invalid;
13862 }
13863
13864
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
13865 {
13866
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc1),f))
13867 {
13868 return qe_invalid;
13869 }
13870
13871
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc2),f))
13872 {
13873 return qe_invalid;
13874 }
13875
13876
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc3),f))
13877 {
13878 return qe_invalid;
13879 }
13880
13881
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc4),f))
13882 {
13883 return qe_invalid;
13884 }
13885
13886
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc5),f))
13887 {
13888 return qe_invalid;
13889 }
13890
13891
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc6),f))
13892 {
13893 return qe_invalid;
13894 }
13895
13896
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc7),f))
13897 {
13898 return qe_invalid;
13899 }
13900
13901
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc8),f))
13902 {
13903 return qe_invalid;
13904 }
13905
13906
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc9),f))
13907 {
13908 return qe_invalid;
13909 }
13910
13911
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc10),f))
13912 {
13913 return qe_invalid;
13914 }
13915 57856 }
13916 else
13917 {
13918 int16_t tempMisc;
13919
13920 if(!p_igetw(&tempMisc,f))
13921 {
13922 return qe_invalid;
13923 }
13924
13925 tempguy.misc1=tempMisc;
13926
13927 if(!p_igetw(&tempMisc,f))
13928 {
13929 return qe_invalid;
13930 }
13931
13932 tempguy.misc2=tempMisc;
13933
13934 if(!p_igetw(&tempMisc,f))
13935 {
13936 return qe_invalid;
13937 }
13938
13939 tempguy.misc3=tempMisc;
13940
13941 if(!p_igetw(&tempMisc,f))
13942 {
13943 return qe_invalid;
13944 }
13945
13946 tempguy.misc4=tempMisc;
13947
13948 if(!p_igetw(&tempMisc,f))
13949 {
13950 return qe_invalid;
13951 }
13952
13953 tempguy.misc5=tempMisc;
13954
13955 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
13956 {
13957 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
13958 tempguy.misc5 = 74;
13959 }
13960
13961 if(!p_igetw(&tempMisc,f))
13962 {
13963 return qe_invalid;
13964 }
13965
13966 tempguy.misc6=tempMisc;
13967
13968 if(!p_igetw(&tempMisc,f))
13969 {
13970 return qe_invalid;
13971 }
13972
13973 tempguy.misc7=tempMisc;
13974
13975 if(!p_igetw(&tempMisc,f))
13976 {
13977 return qe_invalid;
13978 }
13979
13980 tempguy.misc8=tempMisc;
13981
13982 if(!p_igetw(&tempMisc,f))
13983 {
13984 return qe_invalid;
13985 }
13986
13987 tempguy.misc9=tempMisc;
13988
13989 if(!p_igetw(&tempMisc,f))
13990 {
13991 return qe_invalid;
13992 }
13993
13994 tempguy.misc10=tempMisc;
13995 }
13996
13997
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.bgsfx),f))
13998 {
13999 return qe_invalid;
14000 }
14001
14002
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.bosspal),f))
14003 {
14004 return qe_invalid;
14005 }
14006
14007
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.extend),f))
14008 {
14009 return qe_invalid;
14010 }
14011
14012 //! Enemy Defences
14013
14014 //If a 2.50 quest, use only the 2.5 defences.
14015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
57856 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14016 {
14017
2/2
✓ Branch 0 taken 1099264 times.
✓ Branch 1 taken 57856 times.
1157120 for(int32_t j=0; j<edefLAST; j++)
14018 {
14019
1/2
✓ Branch 0 taken 1099264 times.
✗ Branch 1 not taken.
1099264 if(!p_getc(&(tempguy.defense[j]),f))
14020 {
14021 return qe_invalid;
14022 }
14023 1099264 }
14024 //then copy the generic script defence to all the new script defences
14025
14026 57856 }
14027
14028
14029
14030
14031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
57856 if(guyversion >= 18)
14032 {
14033
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.hitsfx),f))
14034 {
14035 return qe_invalid;
14036 }
14037
14038
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.deadsfx),f))
14039 {
14040 return qe_invalid;
14041 }
14042 57856 }
14043
14044
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion >= 22)
14045 {
14046
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc11),f))
14047 {
14048 return qe_invalid;
14049 }
14050
14051
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc12),f))
14052 {
14053 return qe_invalid;
14054 }
14055 57856 }
14056 else if(guyversion >= 19)
14057 {
14058 int16_t tempMisc;
14059
14060 if(!p_igetw(&tempMisc,f))
14061 {
14062 return qe_invalid;
14063 }
14064
14065 tempguy.misc11=tempMisc;
14066
14067 if(!p_igetw(&tempMisc,f))
14068 {
14069 return qe_invalid;
14070 }
14071
14072 tempguy.misc12=tempMisc;
14073 }
14074
14075 //If a 2.54 or later quest, use all of the defences.
14076
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 24) // Add new guyversion conditional statement
14077 {
14078
2/2
✓ Branch 0 taken 405504 times.
✓ Branch 1 taken 18432 times.
423936 for(int32_t j=edefLAST; j<edefLAST255; j++)
14079 {
14080
1/2
✓ Branch 0 taken 405504 times.
✗ Branch 1 not taken.
405504 if(!p_getc(&(tempguy.defense[j]),f))
14081 {
14082 return qe_invalid;
14083 }
14084 405504 }
14085 18432 }
14086
14087
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14088 {
14089
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14090 {
14091 394240 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14092 394240 }
14093 39424 }
14094
14095 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14096
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 25)
14097 {
14098
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.txsz),f))
14099 {
14100 return qe_invalid;
14101 }
14102
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.tysz),f))
14103 {
14104 return qe_invalid;
14105 }
14106
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hxsz),f))
14107 {
14108 return qe_invalid;
14109 }
14110
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hysz),f))
14111 {
14112 return qe_invalid;
14113 }
14114
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hzsz),f))
14115 {
14116 return qe_invalid;
14117 }
14118 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14119
14120 */
14121 18432 }
14122 //More Enemy Editor vars for 2.60
14123
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 26)
14124 {
14125
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hxofs),f))
14126 {
14127 return qe_invalid;
14128 }
14129
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hyofs),f))
14130 {
14131 return qe_invalid;
14132 }
14133
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.xofs),f))
14134 {
14135 return qe_invalid;
14136 }
14137
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.yofs),f))
14138 {
14139 return qe_invalid;
14140 }
14141
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.zofs),f))
14142 {
14143 return qe_invalid;
14144 }
14145 18432 }
14146
14147
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14148 {
14149 39424 tempguy.wpnsprite = 0;
14150 39424 }
14151
14152
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 27)
14153 {
14154
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.wpnsprite),f))
14155 {
14156 return qe_invalid;
14157 }
14158 18432 }
14159
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14160 {
14161 39424 tempguy.SIZEflags = 0;
14162 39424 }
14163
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 28)
14164 {
14165
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.SIZEflags),f))
14166 {
14167 return qe_invalid;
14168 }
14169
14170 18432 }
14171
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14172 {
14173 39424 tempguy.frozentile = 0;
14174 39424 tempguy.frozencset = 0;
14175 39424 tempguy.frozenclock = 0;
14176
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14177 39424 }
14178
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 30)
14179 {
14180
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozentile),f))
14181 {
14182 return qe_invalid;
14183 }
14184
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozencset),f))
14185 {
14186 return qe_invalid;
14187 }
14188
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozenclock),f))
14189 {
14190 return qe_invalid;
14191 }
14192
2/2
✓ Branch 0 taken 184320 times.
✓ Branch 1 taken 18432 times.
202752 for ( int32_t q = 0; q < 10; q++ ) {
14193
1/2
✓ Branch 0 taken 184320 times.
✗ Branch 1 not taken.
184320 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14194 {
14195 return qe_invalid;
14196 }
14197 184320 }
14198
14199 18432 }
14200
14201
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 34)
14202 {
14203
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.firesfx),f))
14204 {
14205 return qe_invalid;
14206 }
14207
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc16),f))
14208 {
14209 return qe_invalid;
14210 }
14211
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc17),f))
14212 {
14213 return qe_invalid;
14214 }
14215
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc18),f))
14216 {
14217 return qe_invalid;
14218 }
14219
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc19),f))
14220 {
14221 return qe_invalid;
14222 }
14223
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc20),f))
14224 {
14225 return qe_invalid;
14226 }
14227
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc21),f))
14228 {
14229 return qe_invalid;
14230 }
14231
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc22),f))
14232 {
14233 return qe_invalid;
14234 }
14235
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc23),f))
14236 {
14237 return qe_invalid;
14238 }
14239
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc24),f))
14240 {
14241 return qe_invalid;
14242 }
14243
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc25),f))
14244 {
14245 return qe_invalid;
14246 }
14247
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc26),f))
14248 {
14249 return qe_invalid;
14250 }
14251
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc27),f))
14252 {
14253 return qe_invalid;
14254 }
14255
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc28),f))
14256 {
14257 return qe_invalid;
14258 }
14259
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc29),f))
14260 {
14261 return qe_invalid;
14262 }
14263
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc30),f))
14264 {
14265 return qe_invalid;
14266 }
14267
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc31),f))
14268 {
14269 return qe_invalid;
14270 }
14271
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc32),f))
14272 {
14273 return qe_invalid;
14274 }
14275
14276
2/2
✓ Branch 0 taken 589824 times.
✓ Branch 1 taken 18432 times.
608256 for ( int32_t q = 0; q < 32; q++ ) {
14277
1/2
✓ Branch 0 taken 589824 times.
✗ Branch 1 not taken.
589824 if(!p_igetl(&(tempguy.movement[q]),f))
14278 {
14279 return qe_invalid;
14280 }
14281 589824 }
14282
2/2
✓ Branch 0 taken 589824 times.
✓ Branch 1 taken 18432 times.
608256 for ( int32_t q = 0; q < 32; q++ ) {
14283
1/2
✓ Branch 0 taken 589824 times.
✗ Branch 1 not taken.
589824 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14284 {
14285 return qe_invalid;
14286 }
14287 589824 }
14288
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.script),f))
14289 {
14290 return qe_invalid;
14291 }
14292 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14293
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14294 {
14295
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&(tempguy.initD[q]),f))
14296 {
14297 return qe_invalid;
14298 }
14299 147456 }
14300
2/2
✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 18432 times.
55296 for ( int32_t q = 0; q < 2; q++ )
14301 {
14302
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(!p_igetl(&(tempguy.initA[q]),f))
14303 {
14304 return qe_invalid;
14305 }
14306 36864 }
14307
14308 18432 }
14309
14310
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 37)
14311 {
14312
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.editorflags),f))
14313 {
14314 return qe_invalid;
14315 }
14316 18432 }
14317
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14318
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 38)
14319 {
14320
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc13),f))
14321 {
14322 return qe_invalid;
14323 }
14324
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc14),f))
14325 {
14326 return qe_invalid;
14327 }
14328
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc15),f))
14329 {
14330 return qe_invalid;
14331 }
14332
14333 18432 }
14334
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 38 )
14335 {
14336 39424 tempguy.misc13 = 0;
14337 39424 tempguy.misc14 = 0;
14338 39424 tempguy.misc15 = 0;
14339 39424 }
14340
14341
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 39 )
14342 {
14343
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14344 {
14345
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
14346 {
14347
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14348 {
14349 return qe_invalid;
14350 }
14351 9584640 }
14352
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
14353 {
14354
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14355 {
14356 return qe_invalid;
14357 }
14358 9584640 }
14359 147456 }
14360
14361
14362 18432 }
14363
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 39 ) //apply old InitD strings to both
14364 {
14365
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ )
14366 {
14367 315392 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14368 315392 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14369 315392 }
14370 39424 }
14371
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 40 )
14372 {
14373
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.weaponscript),f))
14374 {
14375 return qe_invalid;
14376 }
14377 18432 }
14378
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 40 )
14379 {
14380 39424 tempguy.weaponscript = 0;
14381 39424 }
14382 //eweapon script InitD
14383
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 41 )
14384 {
14385
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14386 {
14387
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14388 {
14389 return qe_invalid;
14390 }
14391 147456 }
14392
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if ( guy_cversion < 4 )
14393 {
14394 if ( tempguy.family == eeKEESE )
14395 {
14396
14397 if ( !tempguy.misc1 )
14398 {
14399 tempguy.misc16 = 120;
14400 tempguy.misc17 = 16;
14401
14402 }
14403 }
14404 if ( tempguy.family == eePEAHAT )
14405 {
14406 tempguy.misc16 = 80;
14407 tempguy.misc17 = 16;
14408 }
14409
14410 if ( tempguy.family == eeGHINI )
14411 {
14412 tempguy.misc16 = 120;
14413 tempguy.misc17 = 10;
14414 }
14415
14416 }
14417 18432 }
14418
14419
14420
14421 //default weapon sprites (quest version < 2.54)
14422 //port over old defaults -Z
14423
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 32)
14424 {
14425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.wpnsprite <= 0 )
14426 {
14427
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14428 {
14429 case wNone:
14430 32842 tempguy.wpnsprite = 0; break;
14431
14432 case wSword:
14433 case wBeam:
14434 case wBrang:
14435 case wBomb:
14436 case wSBomb:
14437 case wLitBomb:
14438 case wLitSBomb:
14439 case wArrow:
14440 case wFire:
14441 case wWhistle:
14442 case wBait:
14443 case wWand:
14444 case wMagic:
14445 case wCatching:
14446 case wWind:
14447 case wRefMagic:
14448 case wRefFireball:
14449 case wRefRock:
14450 case wHammer:
14451 case wHookshot:
14452 case wHSHandle:
14453 case wHSChain:
14454 case wSSparkle:
14455 case wFSparkle:
14456 case wSmack:
14457 case wPhantom:
14458 case wCByrna:
14459 case wRefBeam:
14460 case wStomp:
14461 case lwMax:
14462 case wScript1:
14463 case wScript2:
14464 case wScript3:
14465 case wScript4:
14466 case wScript5:
14467 case wScript6:
14468 case wScript7:
14469 case wScript8:
14470 case wScript9:
14471 case wScript10:
14472 case wIce:
14473 //Cannot use any of these weapons yet.
14474 tempguy.wpnsprite = -1;
14475 break;
14476
14477 case wEnemyWeapons:
14478 1303 case ewFireball: tempguy.wpnsprite = 17; break;
14479
14480 302 case ewArrow: tempguy.wpnsprite = 19; break;
14481 314 case ewBrang: tempguy.wpnsprite = 4; break;
14482 931 case ewSword: tempguy.wpnsprite = 20; break;
14483 493 case ewRock: tempguy.wpnsprite = 18; break;
14484 912 case ewMagic: tempguy.wpnsprite = 21; break;
14485 80 case ewBomb: tempguy.wpnsprite = 78; break;
14486 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14487 137 case ewLitBomb: tempguy.wpnsprite = 76; break;
14488 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14489 363 case ewFireTrail: tempguy.wpnsprite = 80; break;
14490 759 case ewFlame: tempguy.wpnsprite = 35; break;
14491 106 case ewWind: tempguy.wpnsprite = 36; break;
14492 80 case ewFlame2: tempguy.wpnsprite = 81; break;
14493 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14494 case ewIce: tempguy.wpnsprite = 83; break;
14495 765 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14496
14497
14498 default: break; //No assign.
14499 }
14500 39424 }
14501 39424 }
14502
14503 //default weapon fire sound (quest version < 2.54)
14504 //port over old defaults and zero new data. -Z
14505
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 34)
14506 {
14507
2/2
✓ Branch 0 taken 1261568 times.
✓ Branch 1 taken 39424 times.
1300992 for ( int32_t q = 0; q < 32; q++ )
14508 {
14509 1261568 tempguy.movement[q] = 0;
14510 1261568 tempguy.new_weapon[q] = 0;
14511
14512 1261568 }
14513
14514 //NPC Script attributes.
14515 39424 tempguy.script = 0; //No scripted enemies existed. -Z
14516
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14517
2/2
✓ Branch 0 taken 78848 times.
✓ Branch 1 taken 39424 times.
118272 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14518
14519 39424 tempguy.misc16 = 0;
14520 39424 tempguy.misc17 = 0;
14521 39424 tempguy.misc18 = 0;
14522 39424 tempguy.misc19 = 0;
14523 39424 tempguy.misc20 = 0;
14524 39424 tempguy.misc21 = 0;
14525 39424 tempguy.misc22 = 0;
14526 39424 tempguy.misc23 = 0;
14527 39424 tempguy.misc24 = 0;
14528 39424 tempguy.misc25 = 0;
14529 39424 tempguy.misc26 = 0;
14530 39424 tempguy.misc27 = 0;
14531 39424 tempguy.misc28 = 0;
14532 39424 tempguy.misc29 = 0;
14533 39424 tempguy.misc30 = 0;
14534 39424 tempguy.misc31 = 0;
14535 39424 tempguy.misc32 = 0;
14536
14537 //old default sounds
14538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.firesfx <= 0 )
14539 {
14540
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14541 {
14542 case wNone:
14543 32842 tempguy.firesfx = 0; break;
14544
14545 case wSword:
14546 case wBeam:
14547 case wBrang:
14548 case wBomb:
14549 case wSBomb:
14550 case wLitBomb:
14551 case wLitSBomb:
14552 case wArrow:
14553 case wFire:
14554 case wWhistle:
14555 case wBait:
14556 case wWand:
14557 case wMagic:
14558 case wCatching:
14559 case wWind:
14560 case wRefMagic:
14561 case wRefFireball:
14562 case wRefRock:
14563 case wHammer:
14564 case wHookshot:
14565 case wHSHandle:
14566 case wHSChain:
14567 case wSSparkle:
14568 case wFSparkle:
14569 case wSmack:
14570 case wPhantom:
14571 case wCByrna:
14572 case wRefBeam:
14573 case wStomp:
14574 case lwMax:
14575 case wScript1:
14576 case wScript2:
14577 case wScript3:
14578 case wScript4:
14579 case wScript5:
14580 case wScript6:
14581 case wScript7:
14582 case wScript8:
14583 case wScript9:
14584 case wScript10:
14585 case wIce:
14586 //Cannot use any of these weapons yet.
14587 tempguy.firesfx = -1;
14588 break;
14589
14590 case wEnemyWeapons:
14591 1303 case ewFireball: tempguy.firesfx = 40; break;
14592
14593 302 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14594 314 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14595 931 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14596 493 case ewRock: tempguy.firesfx = 51; break;
14597 912 case ewMagic: tempguy.firesfx = 32; break;
14598 80 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14599 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14600 137 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14601 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14602 363 case ewFireTrail: tempguy.firesfx = 13; break;
14603 759 case ewFlame: tempguy.firesfx = 13; break;
14604 106 case ewWind: tempguy.firesfx = 32; break;
14605 80 case ewFlame2: tempguy.firesfx = 13; break;
14606 case ewFlame2Trail: tempguy.firesfx = 13; break;
14607 case ewIce: tempguy.firesfx = 44; break;
14608 765 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14609
14610 //what about special attacks (e.g. summoning == 56)
14611 default: break; //No assign.
14612 }
14613 39424 }
14614 39424 }
14615
14616 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14617
4/6
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
✓ Branch 2 taken 18432 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18432 times.
57856 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14618 {
14619
2/2
✓ Branch 0 taken 3549 times.
✓ Branch 1 taken 35875 times.
39424 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14620 39424 }
14621 //Keese and bat halt rates.
14622
3/4
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39424 times.
57856 if ( guyversion < 42 && guy_cversion < 4 )
14623 {
14624
14625
2/2
✓ Branch 0 taken 38895 times.
✓ Branch 1 taken 529 times.
39424 if ( tempguy.family == eeKEESE )
14626 {
14627
14628
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 326 times.
529 if ( !tempguy.misc1 )
14629 {
14630 326 tempguy.misc16 = 120;
14631 326 tempguy.misc17 = 16;
14632
14633 326 }
14634 529 }
14635
2/2
✓ Branch 0 taken 39257 times.
✓ Branch 1 taken 167 times.
39424 if ( tempguy.family == eePEAHAT )
14636 {
14637 167 tempguy.misc16 = 80;
14638 167 tempguy.misc17 = 16;
14639 167 }
14640
2/2
✓ Branch 0 taken 39347 times.
✓ Branch 1 taken 77 times.
39424 if ( tempguy.family == eeGHINI )
14641 {
14642 77 tempguy.misc16 = 120;
14643 77 tempguy.misc17 = 10;
14644 77 }
14645
14646
14647 39424 }
14648
14649
14650 //miscellaneous other corrections
14651 //fix the mirror wizzrobe -DD
14652
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 7)
14653 {
14654 if(i == eMWIZ)
14655 {
14656 tempguy.misc2 = 0;
14657 tempguy.misc4 = 1;
14658 }
14659 }
14660
14661
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 8)
14662 {
14663 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14664 {
14665 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14666 tempguy.misc5 = 4; //neck length in segments
14667 tempguy.misc6 = 8; //neck offset from first body tile
14668 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14669 tempguy.misc8 = 168; //head offset from first body tile
14670 tempguy.misc9 = 228; //flying head offset from first body tile
14671
14672 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14673 {
14674 tempguy.misc6 += 10; //neck offset from first body tile
14675 tempguy.misc8 -= 12; //head offset from first body tile
14676 }
14677 }
14678 }
14679
14680
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14681 {
14682 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14683 tempguy.bosspal = spDIG;
14684 }
14685
14686
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 11) // December 2007 - Spinning Tile fix
14687 {
14688 if(tempguy.family==eeSPINTILE)
14689 {
14690 tempguy.flags |= guy_superman;
14691 tempguy.item_set = 0; // Don't drop items
14692 tempguy.step = 300;
14693 }
14694 }
14695
14696
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14697 {
14698 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14699 {
14700 if(tempguy.family==eeROPE)
14701 {
14702 tempguy.flags2 &= ~guy_flashing;
14703 }
14704 }
14705
14706 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14707 {
14708 if(tempguy.family==eeBUBBLE)
14709 {
14710 tempguy.flags2 &= ~guy_flashing;
14711 }
14712 }
14713
14714 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14715 {
14716 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14717 {
14718 tempguy.flags2 |= guy_blinking;
14719 }
14720
14721 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14722 {
14723 tempguy.flags2 |= guy_transparent;
14724 }
14725 }
14726 }
14727
14728
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14729 {
14730 if(i==gFIRE)
14731 {
14732 tempguy.e_anim = aFLIP;
14733 tempguy.e_frate = 24;
14734 }
14735
14736 if(i==gFAIRY)
14737 {
14738 tempguy.e_anim = a2FRM;
14739 tempguy.e_frate = 16;
14740 }
14741 }
14742
14743
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14744 {
14745 if(i==0) Z_message("Updating guys to version 16...\n");
14746
14747 update_guy_1(&tempguy);
14748
14749 if(i==eMPOLSV)
14750 {
14751 tempguy.defense[edefARROW] = edCHINK;
14752 tempguy.defense[edefMAGIC] = ed1HKO;
14753 tempguy.defense[edefREFMAGIC] = ed1HKO;
14754 }
14755 }
14756
14757
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 17) // December 2009
14758 {
14759 if(tempguy.family==eePROJECTILE)
14760 {
14761 tempguy.misc1 = 0;
14762 }
14763 }
14764
14765
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 18) // January 2010
14766 {
14767 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14768 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14769
14770 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14771 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
14772
14773 if(tempguy.family == eeAQUA)
14774 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14775 else if(tempguy.family == eeMANHAN)
14776 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14777 else if(tempguy.family==eePATRA)
14778 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14779 else if(tempguy.family==eeGHOMA)
14780 {
14781 for(int32_t j=0; j<edefLAST; j++)
14782 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14783
14784 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
14785
14786 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14787
14788 tempguy.misc1--;
14789 }
14790 else if(tempguy.family == eeGLEEOK)
14791 {
14792 for(int32_t j=0; j<edefLAST; j++)
14793 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14794
14795 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14796 }
14797 else if(tempguy.family == eeARMOS)
14798 {
14799 tempguy.family=eeWALK;
14800 tempguy.hrate = 0;
14801 tempguy.misc10 = tempguy.misc1;
14802 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
14803 tempguy.misc9 = e9tARMOS;
14804 }
14805 else if(tempguy.family == eeGHINI && !tempguy.misc1)
14806 {
14807 tempguy.family=eeWALK;
14808 tempguy.hrate = 0;
14809 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
14810 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
14811 }
14812
14813 // Spawn animation flags
14814 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
14815 tempguy.flags |= guy_fadeflicker;
14816 else
14817 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
14818 }
14819
14820
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 20) // April 2010
14821 {
14822 if(tempguy.family == eeTRAP)
14823 {
14824 tempguy.misc2 = tempguy.misc10;
14825
14826 if(tempguy.misc10>=1)
14827 {
14828 tempguy.misc1++;
14829 }
14830
14831 tempguy.misc10 = 0;
14832 }
14833
14834 // Bomb Blast fix
14835 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14836 tempguy.weapon = ewLitBomb;
14837 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14838 tempguy.weapon = ewLitSBomb;
14839 }
14840
14841
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 21) // September 2011
14842 {
14843 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14844 {
14845 if(tempguy.family == eeKEESETRIB)
14846 {
14847 tempguy.family = eeKEESE;
14848 tempguy.misc2 = e2tKEESETRIB;
14849 tempguy.misc1 = 0;
14850 }
14851
14852 tempguy.rate = 2;
14853 tempguy.hrate = 8;
14854 tempguy.homing = 0;
14855 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
14856 }
14857 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14858 {
14859 if(tempguy.family == eePEAHAT)
14860 {
14861 tempguy.rate = 4;
14862 tempguy.step = 62;
14863 }
14864 else
14865 tempguy.step = 25;
14866
14867 tempguy.hrate = 8;
14868 tempguy.homing = 0;
14869 }
14870 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14871 {
14872 if(tempguy.family == eeMANHAN)
14873 tempguy.step=50;
14874
14875 tempguy.hrate = 16;
14876 tempguy.homing = 0;
14877 }
14878 else if(tempguy.family == eeGLEEOK)
14879 {
14880 tempguy.rate = 2;
14881 tempguy.homing = 0;
14882 tempguy.hrate = 9;
14883 tempguy.step=89;
14884 }
14885 else if(tempguy.family == eeGHINI)
14886 {
14887 tempguy.rate = 4;
14888 tempguy.hrate = 12;
14889 tempguy.step=62;
14890 tempguy.homing = 0;
14891 }
14892
14893 // Bigdig random rate fix
14894 if(tempguy.family==eeDIG && tempguy.misc10==1)
14895 {
14896 tempguy.rate = 2;
14897 }
14898 }
14899
14900
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 24) // November 2012
14901 {
14902 if(tempguy.family==eeLANM)
14903 tempguy.misc3 = 1;
14904 else if(tempguy.family==eeMOLD)
14905 tempguy.misc2 = 0;
14906 }
14907
14908
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14909 {
14910
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 38764 times.
39424 if(tempguy.family!=eeDIG)
14911 {
14912 38764 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14913 38764 }
14914
14915 39424 }
14916 // does not seem to solve the issue!
14917
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if ( Header->zelda_version <= 0x210 )
14918 {
14919 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14920 if ( tempguy.family == eeDONGO )
14921 {
14922 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14923 }
14924 }
14925
14926
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion >= 42)
14927 {
14928
2/2
✓ Branch 0 taken 17408 times.
✓ Branch 1 taken 1024 times.
18432 if(guyversion >= 47)
14929 {
14930
1/2
✓ Branch 0 taken 17408 times.
✗ Branch 1 not taken.
17408 if(!p_igetl(&(tempguy.moveflags),f))
14931 {
14932 return qe_invalid;
14933 }
14934 17408 }
14935 else
14936 {
14937 byte fl;
14938
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f))
14939 {
14940 return qe_invalid;
14941 }
14942 1024 tempguy.moveflags = fl;
14943 }
14944 18432 }
14945 else
14946 {
14947
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30899 times.
✓ Branch 2 taken 1202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 518 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 241 times.
✓ Branch 7 taken 5840 times.
39424 switch(tempguy.family)
14948 {
14949 //No gravity; floats over pits
14950 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14951 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14952 //Special (bosses, etc)
14953 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14954 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14955 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14956 30899 tempguy.moveflags = FLAG_CAN_PITWALK;
14957 30899 break;
14958 //No gravity, but falls in pits
14959 case eeLEV:
14960 518 tempguy.moveflags = FLAG_CAN_PITFALL;
14961 518 break;
14962 //Bosses that respect pits
14963 case eeDONGO:
14964 278 tempguy.moveflags = FLAG_OBEYS_GRAV;
14965 278 break;
14966 case eeLANM:
14967 241 tempguy.moveflags = 0;
14968 241 break;
14969 //Gravity, floats over pits
14970 case eeWIZZ: case eeWALLM: case eeGHINI:
14971 1202 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
14972 1202 break;
14973 //Gravity and falls in pits
14974 case eeWALK:
14975
4/4
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 5239 times.
5840 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
14976 601 break;
14977 [[fallthrough]];
14978 case eeOTHER:
14979 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
14980 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
14981 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
14982 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
14983 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
14984 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
14985 5685 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
14986 5685 }
14987 }
14988
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 43)
14989 {
14990
2/2
✓ Branch 0 taken 32101 times.
✓ Branch 1 taken 7323 times.
39424 switch(tempguy.family)
14991 {
14992 //No gravity; floats over pits
14993 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14994 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14995 //Special (bosses, etc)
14996 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14997 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14998 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14999 case eeWIZZ: case eeWALLM: case eeGHINI:
15000 //Gravity, floats over pits
15001 32101 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15002 32101 break;
15003 }
15004 39424 }
15005
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if (guyversion < 44)
15006 {
15007
2/2
✓ Branch 0 taken 39054 times.
✓ Branch 1 taken 370 times.
39424 if ( tempguy.family == eeGHOMA )
15008 {
15009 370 tempguy.flags |= guy_fadeinstant;
15010 370 }
15011 39424 }
15012
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if (guyversion > 44)
15013 {
15014
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_shadow),f))
15015 {
15016 return qe_invalid;
15017 }
15018
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_death),f))
15019 {
15020 return qe_invalid;
15021 }
15022
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_spawn),f))
15023 {
15024 return qe_invalid;
15025 }
15026 18432 }
15027 else
15028 {
15029
2/2
✓ Branch 0 taken 39271 times.
✓ Branch 1 taken 153 times.
39424 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15030 39424 tempguy.spr_death = iwDeath;
15031 39424 tempguy.spr_spawn = iwSpawn;
15032 }
15033
15034
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 46)
15035 {
15036
4/4
✓ Branch 0 taken 5840 times.
✓ Branch 1 taken 33584 times.
✓ Branch 2 taken 5519 times.
✓ Branch 3 taken 321 times.
39424 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15037 {
15038 321 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15039 321 }
15040 39424 }
15041
15042 57856 guysbuf[i] = tempguy;
15043 57856 }
15044 113 }
15045
15046 113 return 0;
15047 129 }
15048
15049 void update_guy_1(guydata *tempguy) // November 2009
15050 {
15051 bool doesntcount = false;
15052 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15053
15054 switch(tempguy->family)
15055 {
15056 case 1: //eeWALK
15057 switch(tempguy->misc10)
15058 {
15059 case 0: //Stalfos
15060 if(tempguy->misc1==1) // Fires four projectiles at once
15061 tempguy->misc1=4;
15062
15063 break;
15064
15065 case 1: //Darknut
15066 goto darknuts;
15067 break;
15068 }
15069
15070 tempguy->misc10 = 0;
15071 break;
15072
15073 case 2: //eeSHOOT
15074 tempguy->family = eeWALK;
15075
15076 switch(tempguy->misc10)
15077 {
15078 case 0: //Octorok
15079 if(tempguy->misc1==1||tempguy->misc1==2)
15080 {
15081 tempguy->misc1=e1tFIREOCTO;
15082 tempguy->misc2=e2tFIREOCTO;
15083 }
15084 else tempguy->misc1 = 0;
15085
15086 tempguy->misc6=tempguy->misc4;
15087 tempguy->misc4=tempguy->misc3;
15088 tempguy->misc3=0;
15089 break;
15090
15091 case 1: // Moblin
15092 tempguy->misc1 = 0;
15093 break;
15094
15095 case 2: //Lynel
15096 tempguy->misc6=tempguy->misc1+1;
15097 tempguy->misc1=0;
15098 break;
15099
15100 case 3: //Stalfos 2
15101 if(tempguy->misc1==1) // Fires four projectiles at once
15102 tempguy->misc1=e1t4SHOTS;
15103 else tempguy->misc1 = 0;
15104
15105 break;
15106
15107 case 4: //Darknut 5
15108 darknuts:
15109 tempguy->defense[edefFIRE] = edIGNORE;
15110 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15111 tempguy->defense[edefHOOKSHOT] = 0;
15112 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15113 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15114
15115 if(tempguy->misc1==1)
15116 tempguy->misc1=2;
15117 else if(tempguy->misc1==2)
15118 {
15119 tempguy->misc4=tempguy->misc3;
15120 tempguy->misc3=tempguy->misc2;
15121 tempguy->misc2=e2tSPLIT;
15122 tempguy->misc1 = 0;
15123 }
15124 else tempguy->misc1 = 0;
15125
15126 tempguy->flags |= inv_front;
15127
15128 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15129 tempguy->flags |= guy_bkshield;
15130
15131 break;
15132 }
15133
15134 tempguy->misc10 = 0;
15135 break;
15136
15137 /*
15138 case 9: //eeARMOS
15139 tempguy->family = eeWALK;
15140 break;
15141 */
15142 case 11: //eeGEL
15143 case 33: //eeGELTRIB
15144 if(tempguy->family==33)
15145 {
15146 tempguy->misc4 = 1;
15147
15148 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15149 tempguy->misc3 = tempguy->misc2;
15150
15151 tempguy->misc2 = e2tTRIBBLE;
15152 }
15153 else
15154 {
15155 tempguy->misc4 = 0;
15156 tempguy->misc3 = 0;
15157 tempguy->misc2 = 0;
15158 }
15159
15160 tempguy->family = eeWALK;
15161
15162 if(tempguy->misc1)
15163 {
15164 tempguy->misc1=1;
15165 tempguy->weapon = ewFireTrail;
15166 }
15167
15168 break;
15169
15170 case 34: //eeZOLTRIB
15171 case 12: //eeZOL
15172 tempguy->misc4=tempguy->misc3;
15173 tempguy->misc3=tempguy->misc2;
15174 tempguy->family = eeWALK;
15175 tempguy->misc2=e2tSPLITHIT;
15176
15177 if(tempguy->misc1)
15178 {
15179 tempguy->misc1=1;
15180 tempguy->weapon = ewFireTrail;
15181 }
15182
15183 break;
15184
15185 case 13: //eeROPE
15186 tempguy->family = eeWALK;
15187 tempguy->misc9 = e9tROPE;
15188
15189 if(tempguy->misc1)
15190 {
15191 tempguy->misc4 = tempguy->misc3;
15192 tempguy->misc3 = tempguy->misc2;
15193 tempguy->misc2 = e2tBOMBCHU;
15194 }
15195
15196 tempguy->misc1 = 0;
15197 break;
15198
15199 case 14: //eeGORIYA
15200 tempguy->family = eeWALK;
15201
15202 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15203
15204 break;
15205
15206 case 17: //eeBUBBLE
15207 tempguy->family = eeWALK;
15208 tempguy->misc8 = tempguy->misc2;
15209 tempguy->misc7 = tempguy->misc1 + 1;
15210 tempguy->misc1 = tempguy->misc2 = 0;
15211
15212 //fallthrogh
15213 case eeTRAP:
15214 case eeROCK:
15215 doesntcount = true;
15216 break;
15217
15218 case 35: //eeVIRETRIB
15219 case 18: //eeVIRE
15220 tempguy->family = eeWALK;
15221 tempguy->misc4=tempguy->misc3;
15222 tempguy->misc3=tempguy->misc2;
15223 tempguy->misc2=e2tSPLITHIT;
15224 tempguy->misc9=e9tVIRE;
15225 break;
15226
15227 case 19: //eeLIKE
15228 tempguy->family = eeWALK;
15229 tempguy->misc7 = e7tEATITEMS;
15230 tempguy->misc8=95;
15231 break;
15232
15233 case 20: //eePOLSV
15234 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15235 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15236 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15237 tempguy->defense[edefARROW] = ed1HKO;
15238 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15239 tempguy->family = eeWALK;
15240 tempguy->misc9 = e9tPOLSVOICE;
15241 tempguy->rate = 4;
15242 tempguy->homing = 32;
15243 tempguy->hrate = 10;
15244 tempguy->grumble = 0;
15245 break;
15246
15247 case eeWIZZ:
15248 if(tempguy->misc4)
15249 {
15250 for(int32_t i=0; i < edefLAST; i++)
15251 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15252 }
15253 else
15254 {
15255 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15256 tempguy->defense[edefMAGIC] = edCHINK;
15257 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15258 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15259 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15260 }
15261
15262 break;
15263
15264 case eePEAHAT:
15265 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15266
15267 if(!(tempguy->flags & guy_bhit))
15268 tempguy->defense[edefBRANG] = edSTUNONLY;
15269
15270 break;
15271
15272 case eeLEV:
15273 tempguy->defense[edefSTOMP] = edCHINK;
15274 break;
15275 }
15276
15277 // Old flags
15278 if(tempguy->flags & guy_superman)
15279 {
15280 for(int32_t i = 0; i < edefLAST; i++)
15281 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15282 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15283 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15284 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15285 }
15286
15287 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15288
15289 if(doesntcount)
15290 tempguy->flags |= (guy_doesntcount);
15291 }
15292
15293
15294 247176 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15295 {
15296 byte tempbyte, padding;
15297 int32_t extras, secretcombos;
15298 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->valid),f))
15300 {
15301 return qe_invalid;
15302 }
15303
15304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->guy),f))
15305 return qe_invalid;
15306 247176 temp_mapscr->guytile = -1; //signal to use default guy values
15307
2/2
✓ Branch 0 taken 246700 times.
✓ Branch 1 taken 476 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15308
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 246700 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 453 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15309
15310
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15311 {
15312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15313 {
15314 return qe_invalid;
15315 }
15316
15317 6864 temp_mapscr->str=tempbyte;
15318 6864 }
15319 else
15320 {
15321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->str),f))
15322 {
15323 return qe_invalid;
15324 }
15325 }
15326
15327
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->room),f))
15328 {
15329 return qe_invalid;
15330 }
15331
15332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->item),f))
15333 {
15334 return qe_invalid;
15335 }
15336
15337
3/6
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15338 {
15339 93768 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15340 93768 }
15341 else
15342 {
15343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->hasitem),f))
15344 return qe_invalid;
15345 }
15346
15347
2/4
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version < 0x192)||
15348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15349 {
15350
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15351 {
15352 return qe_invalid;
15353 }
15354 6864 }
15355
15356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15357 {
15358 return qe_invalid;
15359 }
15360
15361
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15362 {
15363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15364 {
15365 return qe_invalid;
15366 }
15367 6864 }
15368
15369
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15370 {
15371
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15372 {
15373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15374 {
15375 return qe_invalid;
15376 }
15377 460224 }
15378 153408 }
15379 else
15380 {
15381 93768 temp_mapscr->tilewarptype[1]=0;
15382 93768 temp_mapscr->tilewarptype[2]=0;
15383 93768 temp_mapscr->tilewarptype[3]=0;
15384 }
15385
15386
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15387 {
15388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15389 {
15390 return qe_invalid;
15391 }
15392 240312 }
15393
15394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15395 {
15396 return qe_invalid;
15397 }
15398
15399 247176 temp_mapscr->warpreturnx[1]=0;
15400 247176 temp_mapscr->warpreturnx[2]=0;
15401 247176 temp_mapscr->warpreturnx[3]=0;
15402
15403
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15404 {
15405
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15406 {
15407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15408 {
15409 return qe_invalid;
15410 }
15411 460224 }
15412 153408 }
15413
15414
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15415 {
15416 return qe_invalid;
15417 }
15418
15419 247176 temp_mapscr->warpreturny[1]=0;
15420 247176 temp_mapscr->warpreturny[2]=0;
15421 247176 temp_mapscr->warpreturny[3]=0;
15422
15423
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15424 {
15425
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15426 {
15427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15428 {
15429 return qe_invalid;
15430 }
15431 460224 }
15432
15433
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(version>=18)
15434 {
15435
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15436 {
15437 return qe_invalid;
15438 }
15439 153408 }
15440 else
15441 {
15442 byte temp;
15443
15444 if(!p_getc(&temp,f))
15445 {
15446 return qe_invalid;
15447 }
15448
15449 temp_mapscr->warpreturnc=temp<<8|temp;
15450 }
15451 153408 }
15452
15453
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->stairx),f))
15454
15455 {
15456 return qe_invalid;
15457 }
15458
15459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->stairy),f))
15460 {
15461 return qe_invalid;
15462 }
15463
15464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemx),f))
15465 {
15466 return qe_invalid;
15467 }
15468
15469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemy),f))
15470 {
15471 return qe_invalid;
15472 }
15473
15474
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version > 15) // February 2009
15475 {
15476
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->color),f))
15477 {
15478 return qe_invalid;
15479 }
15480 153408 }
15481 else
15482 {
15483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93768 times.
93768 if(!p_getc(& tempbyte,f))
15484 {
15485 return qe_invalid;
15486 }
15487
15488 93768 temp_mapscr->color = (word) tempbyte;
15489 }
15490
15491
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->enemyflags),f))
15492 {
15493 return qe_invalid;
15494 }
15495
15496
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15497 {
15498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->door[k]),f))
15499 {
15500 return qe_invalid;
15501
15502 }
15503 988704 }
15504
15505
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15506 {
15507
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15508 {
15509 return qe_invalid;
15510 }
15511
15512 93768 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15513
15514
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15515 {
15516 for(int32_t i=1; i<4; i++)
15517 {
15518 if(!p_getc(&(tempbyte),f))
15519 {
15520 return qe_invalid;
15521 }
15522
15523 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15524 }
15525 }
15526 else
15527 {
15528 93768 temp_mapscr->tilewarpdmap[1]=0;
15529 93768 temp_mapscr->tilewarpdmap[2]=0;
15530 93768 temp_mapscr->tilewarpdmap[3]=0;
15531 }
15532 93768 }
15533 else
15534 {
15535
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15536 {
15537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15538 {
15539 return qe_invalid;
15540 }
15541 613632 }
15542 }
15543
15544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15545 {
15546 return qe_invalid;
15547 }
15548
15549
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15550 {
15551
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15552 {
15553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15554 {
15555 return qe_invalid;
15556 }
15557 460224 }
15558 153408 }
15559 else
15560 {
15561 93768 temp_mapscr->tilewarpscr[1]=0;
15562 93768 temp_mapscr->tilewarpscr[2]=0;
15563 93768 temp_mapscr->tilewarpscr[3]=0;
15564 }
15565
15566
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15567 {
15568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15569 {
15570 return qe_invalid;
15571 }
15572 153408 }
15573 else
15574 {
15575 93768 temp_mapscr->tilewarpoverlayflags=0;
15576 }
15577
15578
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->exitdir),f))
15579 {
15580 return qe_invalid;
15581 }
15582
15583
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15584 {
15585
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15586 {
15587 return qe_invalid;
15588 }
15589
15590 6864 }
15591
15592
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15593 {
15594 if(!p_getc(&padding,f))
15595 {
15596 return qe_invalid;
15597 }
15598 }
15599
15600
2/2
✓ Branch 0 taken 2471760 times.
✓ Branch 1 taken 247176 times.
2718936 for(int32_t k=0; k<10; k++)
15601 {
15602 /*
15603 if (!temp_mapscr->enemy[k])
15604 {
15605 continue;
15606 }
15607 */
15608
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15609 {
15610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f))
15611 {
15612 return qe_invalid;
15613 }
15614
15615 68640 temp_mapscr->enemy[k]=tempbyte;
15616 68640 }
15617 else
15618 {
15619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2403120 times.
2403120 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15620 {
15621 return qe_invalid;
15622 }
15623 }
15624
15625
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15626 {
15627 //using enumerations here is dangerous
15628 //very easy to break old quests -DD
15629
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15630 {
15631 788 temp_mapscr->enemy[k]+=5;
15632 788 }
15633
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15634 {
15635 40 temp_mapscr->enemy[k]+=1;
15636 40 }
15637 68640 }
15638
15639
2/2
✓ Branch 0 taken 1534080 times.
✓ Branch 1 taken 937680 times.
2471760 if(version < 9)
15640 {
15641
2/2
✓ Branch 0 taken 856505 times.
✓ Branch 1 taken 81175 times.
937680 if(temp_mapscr->enemy[k]>0)
15642 {
15643 81175 temp_mapscr->enemy[k]+=10;
15644 81175 }
15645 937680 }
15646 //don't read in any invalid data
15647
2/2
✓ Branch 0 taken 2471670 times.
✓ Branch 1 taken 90 times.
2471760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15648 {
15649 90 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15650 90 temp_mapscr->enemy[k] = 0;
15651 90 }
15652 2471760 }
15653
15654
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->pattern),f))
15655 {
15656 return qe_invalid;
15657 }
15658
15659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15660 {
15661 return qe_invalid;
15662 }
15663
15664
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15665 {
15666
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15667 {
15668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15669 {
15670 return qe_invalid;
15671 }
15672 460224 }
15673 153408 }
15674 else
15675 {
15676 93768 temp_mapscr->sidewarptype[1]=0;
15677 93768 temp_mapscr->sidewarptype[2]=0;
15678 93768 temp_mapscr->sidewarptype[3]=0;
15679 }
15680
15681
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15682 {
15683
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15684 {
15685 return qe_invalid;
15686 }
15687 153408 }
15688 else
15689 {
15690 93768 temp_mapscr->sidewarpoverlayflags=0;
15691 }
15692
15693
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15694 {
15695 return qe_invalid;
15696 }
15697
15698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15699 {
15700 return qe_invalid;
15701 }
15702
15703
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15704 {
15705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->path[k]),f))
15706 {
15707 return qe_invalid;
15708 }
15709 988704 }
15710
15711
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15712 {
15713 return qe_invalid;
15714 }
15715
15716
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15717 {
15718
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 460224 times.
613632 for(int32_t i=1; i<4; i++)
15719 {
15720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15721 {
15722 return qe_invalid;
15723 }
15724 460224 }
15725 153408 }
15726 else
15727 {
15728 93768 temp_mapscr->sidewarpscr[1]=0;
15729 93768 temp_mapscr->sidewarpscr[2]=0;
15730 93768 temp_mapscr->sidewarpscr[3]=0;
15731 }
15732
15733
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15734 {
15735
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15736 {
15737 return qe_invalid;
15738 }
15739
15740 93768 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15741
15742
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15743 {
15744 for(int32_t i=1; i<4; i++)
15745 {
15746 if(!p_getc(&(tempbyte),f))
15747 {
15748 return qe_invalid;
15749 }
15750
15751 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15752 }
15753 }
15754 else
15755 {
15756 93768 temp_mapscr->sidewarpdmap[1]=0;
15757 93768 temp_mapscr->sidewarpdmap[2]=0;
15758 93768 temp_mapscr->sidewarpdmap[3]=0;
15759 }
15760 93768 }
15761 else
15762 {
15763
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15764 {
15765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15766 {
15767 return qe_invalid;
15768 }
15769 613632 }
15770 }
15771
15772
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15773 {
15774
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15775 {
15776 return qe_invalid;
15777 }
15778 153408 }
15779 93768 else temp_mapscr->sidewarpindex = 0;
15780
15781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_igetw(&(temp_mapscr->undercombo),f))
15782 {
15783 return qe_invalid;
15784 }
15785
15786
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15787 {
15788
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f))
15789 {
15790 return qe_invalid;
15791 }
15792 6864 }
15793
15794
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15795 {
15796 return qe_invalid;
15797 }
15798
15799
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_igetw(&(temp_mapscr->catchall),f))
15800 {
15801 return qe_invalid;
15802 }
15803
15804
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->flags),f))
15805 {
15806 return qe_invalid;
15807 }
15808
15809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags2),f))
15810 {
15811 return qe_invalid;
15812 }
15813
15814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags3),f))
15815 {
15816 return qe_invalid;
15817 }
15818
15819
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15820 //if (version>2)
15821 {
15822
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags4),f))
15823 {
15824 return qe_invalid;
15825 }
15826 153408 }
15827
15828
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15829 {
15830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags5),f))
15831 {
15832 return qe_invalid;
15833 }
15834
15835
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->noreset),f))
15836 {
15837 return qe_invalid;
15838 }
15839
15840
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->nocarry),f))
15841 {
15842 return qe_invalid;
15843 }
15844
15845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(temp_mapscr->flags5&32)
15846 {
15847 temp_mapscr->flags5 &= ~32;
15848 temp_mapscr->noreset |= 48;
15849 }
15850
15851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(version<8)
15852 {
15853 if(temp_mapscr->noreset&1)
15854 {
15855 temp_mapscr->noreset|=8192;
15856 }
15857
15858 if(temp_mapscr->nocarry&1)
15859 {
15860 temp_mapscr->nocarry|=8192;
15861 temp_mapscr->nocarry&=~1;
15862 }
15863 }
15864 153408 }
15865 else
15866 {
15867 93768 temp_mapscr->flags5 = 0;
15868 93768 temp_mapscr->noreset = 0;
15869 93768 temp_mapscr->nocarry = 0;
15870 }
15871
15872
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
15873 {
15874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags6),f))
15875 {
15876 return qe_invalid;
15877 }
15878 153408 }
15879
15880
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>5)
15881 {
15882
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags7),f))
15883 {
15884 return qe_invalid;
15885 }
15886
15887
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags8),f))
15888 {
15889 return qe_invalid;
15890 }
15891
15892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags9),f))
15893 {
15894 return qe_invalid;
15895 }
15896
15897
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags10),f))
15898 {
15899 return qe_invalid;
15900 }
15901
15902
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->csensitive),f))
15903 {
15904 return qe_invalid;
15905 }
15906 153408 }
15907 else
15908 {
15909 93768 temp_mapscr->csensitive=1;
15910 }
15911
15912
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<14) // August 2007: screen SFX added
15913 {
15914
2/2
✓ Branch 0 taken 93668 times.
✓ Branch 1 taken 100 times.
93768 if(temp_mapscr->flags&8) //fROAR
15915 {
15916 100 temp_mapscr->bosssfx=
15917
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
15918 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
15919 WAV_ROAR;
15920 100 }
15921
15922
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 93677 times.
93768 if(temp_mapscr->flags&128) //fSEA
15923 {
15924 91 temp_mapscr->oceansfx=WAV_SEA;
15925 91 }
15926
15927 93768 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
15928 ? 0 : WAV_SECRET;
15929
15930 93768 temp_mapscr->flags3 &= ~66; //64|2
15931 93768 temp_mapscr->flags2 &= ~32;
15932 93768 temp_mapscr->flags &= ~136; // 128|8
15933 93768 }
15934 else
15935 {
15936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->oceansfx),f))
15937 {
15938 return qe_invalid;
15939 }
15940
15941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->bosssfx),f))
15942 {
15943 return qe_invalid;
15944 }
15945
15946
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->secretsfx),f))
15947 {
15948 return qe_invalid;
15949 }
15950 }
15951
15952
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<15) // October 2007: another SFX
15953 {
15954 93768 temp_mapscr->holdupsfx=WAV_PICKUP;
15955 93768 }
15956 else
15957 {
15958
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->holdupsfx),f))
15959 {
15960 return qe_invalid;
15961 }
15962 }
15963
15964
15965
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
15966 {
15967
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
15968 {
15969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layermap[k]),f))
15970 {
15971 return qe_invalid;
15972 }
15973 1441872 }
15974
15975
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 1441872 times.
1682184 for(int32_t k=0; k<6; k++)
15976 {
15977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
15978 {
15979 return qe_invalid;
15980 }
15981 1441872 }
15982 240312 }
15983
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
15984 {
15985 if(!p_getc(&(temp_mapscr->layermap[2]),f))
15986 {
15987 return qe_invalid;
15988 }
15989
15990 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
15991 {
15992 return qe_invalid;
15993 }
15994
15995 if(!p_getc(&(temp_mapscr->layermap[4]),f))
15996 {
15997 return qe_invalid;
15998 }
15999
16000 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16001
16002 {
16003 return qe_invalid;
16004 }
16005 }
16006
16007
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>149))
16008 {
16009 for(int32_t k=0; k<6; k++)
16010 {
16011 if(!p_getc(&tempbyte,f)) //layerxsize
16012 {
16013 return qe_invalid;
16014 }
16015 }
16016
16017 for(int32_t k=0; k<6; k++)
16018 {
16019 if(!p_getc(&tempbyte,f)) //layerxspeed
16020 {
16021 return qe_invalid;
16022 }
16023 }
16024
16025 for(int32_t k=0; k<6; k++)
16026 {
16027 if(!p_getc(&tempbyte,f)) //layerxdelay
16028 {
16029 return qe_invalid;
16030 }
16031 }
16032
16033 for(int32_t k=0; k<6; k++)
16034 {
16035 if(!p_getc(&tempbyte,f)) //layerysize
16036 {
16037 return qe_invalid;
16038 }
16039 }
16040
16041 for(int32_t k=0; k<6; k++)
16042 {
16043 if(!p_getc(&tempbyte,f)) //layeryspeed
16044 {
16045 return qe_invalid;
16046 }
16047 }
16048
16049 for(int32_t k=0; k<6; k++)
16050 {
16051 if(!p_getc(&tempbyte,f)) //layerydelay
16052 {
16053 return qe_invalid;
16054 }
16055 }
16056 }
16057
16058
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16059 {
16060
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16061 {
16062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16063 {
16064 return qe_invalid;
16065 }
16066 1441872 }
16067 240312 }
16068
16069
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16070 {
16071
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 if((Header->zelda_version == 0x192)&&(Header->build>153))
16072 {
16073 if(!p_getc(&padding,f))
16074 {
16075 return qe_invalid;
16076 }
16077 }
16078
16079
1/2
✓ Branch 0 taken 240312 times.
✗ Branch 1 not taken.
240312 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16080 {
16081 return qe_invalid;
16082 }
16083 240312 }
16084
16085
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16086 {
16087 6864 extras=15;
16088 6864 }
16089
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16090 {
16091 extras=11;
16092 }
16093
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16094 {
16095 extras=32;
16096 }
16097
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16098 {
16099 extras=64;
16100 }
16101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 else if(Header->zelda_version < 0x193)
16102 {
16103 extras=62;
16104 }
16105 else
16106
16107 {
16108 240312 extras=0;
16109 }
16110
16111
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 247176 times.
350136 for(int32_t k=0; k<extras; k++)
16112 {
16113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f)) //extra[k]
16114 {
16115 return qe_invalid;
16116 }
16117 102960 }
16118
16119
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16120 //if (version>3)
16121 {
16122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->nextmap),f))
16123 {
16124 return qe_invalid;
16125 }
16126
16127
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->nextscr),f))
16128 {
16129 return qe_invalid;
16130 }
16131 153408 }
16132 else
16133 {
16134 93768 temp_mapscr->nextmap=0;
16135 93768 temp_mapscr->nextscr=0;
16136 }
16137
16138
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16139 {
16140 6864 secretcombos=20;
16141 6864 }
16142
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16143 {
16144 secretcombos=256;
16145 }
16146 else
16147 {
16148 240312 secretcombos=128;
16149 }
16150
16151
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16152 {
16153
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16154 {
16155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f))
16156 {
16157 return qe_invalid;
16158 }
16159
16160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16161 {
16162 137280 temp_mapscr->secretcombo[k]=tempbyte;
16163 137280 }
16164 137280 }
16165 6864 }
16166 else
16167 {
16168
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16169 {
16170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16171 {
16172 return qe_invalid;
16173 }
16174
16175 30759936 }
16176 }
16177
16178
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16179 {
16180
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16181 {
16182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16183 {
16184 return qe_invalid;
16185 }
16186 30759936 }
16187
16188
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16189 {
16190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16191 {
16192 return qe_invalid;
16193 }
16194 30759936 }
16195 240312 }
16196
16197
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16198 {
16199 if(!p_getc(&padding,f))
16200 {
16201 return qe_invalid;
16202 }
16203 }
16204
16205 247176 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16206
16207
2/2
✓ Branch 0 taken 43502976 times.
✓ Branch 1 taken 247176 times.
43750152 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16208 {
16209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43502976 times.
43502976 if(!p_igetw(&(temp_mapscr->data[k]),f))
16210 {
16211 return qe_invalid;
16212 }
16213 43502976 }
16214
16215
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16216 {
16217 if(!p_getc(&padding,f))
16218 {
16219 return qe_invalid;
16220 }
16221
16222 if(!p_getc(&padding,f))
16223 {
16224 return qe_invalid;
16225 }
16226 }
16227
16228
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16229 {
16230
2/2
✓ Branch 0 taken 42294912 times.
✓ Branch 1 taken 240312 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16231 {
16232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16233 {
16234 return qe_invalid;
16235 }
16236
16237
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42294912 if((Header->zelda_version == 0x192)&&(Header->build<24))
16238 {
16239 if(!p_getc(&tempbyte,f))
16240 {
16241 return qe_invalid;
16242 }
16243
16244 if(!p_getc(&tempbyte,f))
16245 {
16246 return qe_invalid;
16247 }
16248
16249 if(!p_getc(&tempbyte,f))
16250 {
16251 return qe_invalid;
16252 }
16253 }
16254 42294912 }
16255 240312 }
16256
16257
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16258 {
16259
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 42294912 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16260 {
16261
16262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->cset[k]),f))
16263 {
16264 return qe_invalid;
16265 }
16266 42294912 }
16267 240312 }
16268
16269
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16270 {
16271 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16272 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16273 6864 }
16274
16275
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16276 {
16277 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16278 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16279 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16280 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16281 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16282 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16283 6864 }
16284
16285
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16286 {
16287
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16288 {
16289
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16290 {
16291 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16292 {
16293 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16294 }
16295 }
16296 else
16297 {
16298
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16299 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16300 {
16301 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16302 1208064 }
16303
16304 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16305 }
16306
16307 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16308 1208064 }
16309 6864 }
16310
16311 /*if(version>12)
16312 {
16313 if(!p_getc(&(temp_mapscr->scrWidth),f))
16314 {
16315 return qe_invalid;
16316 }
16317 if(!p_getc(&(temp_mapscr->scrHeight),f))
16318 {
16319 return qe_invalid;
16320 }
16321 }*/
16322
16323
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>4)
16324 {
16325
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16326 {
16327 return qe_invalid;
16328 }
16329 153408 }
16330 else
16331 {
16332 93768 temp_mapscr->screen_midi = -1;
16333 }
16334
16335
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>=17)
16336 {
16337
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->lens_layer),f))
16338 {
16339 return qe_invalid;
16340 }
16341 153408 }
16342 else
16343 {
16344 93768 temp_mapscr->lens_layer = llNORMAL;
16345 }
16346
16347
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version>6)
16348 {
16349 dword bits;
16350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_igetl(&bits,f))
16351 {
16352 return qe_invalid;
16353 }
16354
16355 int32_t m;
16356 float tempfloat;
16357 word tempw;
16358 153408 temp_mapscr->ffcCountMarkDirty();
16359
16360
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 4909056 times.
5062464 for(m=0; m<32; m++)
16361 {
16362 4909056 ffcdata& tempffc = temp_mapscr->ffcs[m];
16363 4909056 tempffc.clear();
16364
2/2
✓ Branch 0 taken 4886067 times.
✓ Branch 1 taken 22989 times.
4909056 if((bits>>m)&1)
16365 {
16366
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetw(&tempw,f))
16367 {
16368 return qe_invalid;
16369 }
16370 22989 tempffc.setData(tempw);
16371
16372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.cset),f))
16373 {
16374 return qe_invalid;
16375 }
16376
16377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.delay),f))
16378 {
16379 return qe_invalid;
16380 }
16381
16382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(version < 9)
16383 {
16384 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16385 {
16386 return qe_invalid;
16387 }
16388
16389 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16390
16391 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16392 {
16393 return qe_invalid;
16394 }
16395
16396 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16397
16398 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16399 {
16400 return qe_invalid;
16401 }
16402
16403 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16404
16405 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16406 {
16407 return qe_invalid;
16408 }
16409
16410 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16411
16412 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16413 {
16414 return qe_invalid;
16415 }
16416
16417 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16418
16419 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16420 {
16421 return qe_invalid;
16422 }
16423
16424 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16425 }
16426 else
16427 {
16428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.x),f))
16429 {
16430 return qe_invalid;
16431 }
16432
16433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.y),f))
16434 {
16435 return qe_invalid;
16436 }
16437
16438
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetzf(&(tempffc.vx),f))
16439 {
16440 return qe_invalid;
16441 }
16442
16443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.vy),f))
16444 {
16445 return qe_invalid;
16446 }
16447
16448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ax),f))
16449 {
16450 return qe_invalid;
16451 }
16452
16453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ay),f))
16454 {
16455 return qe_invalid;
16456 }
16457 }
16458
16459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.link),f))
16460 {
16461 return qe_invalid;
16462 }
16463
16464
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>7)
16465 {
16466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16467 {
16468 return qe_invalid;
16469 }
16470
16471 22989 tempffc.hit_width = (tempbyte&0x3F)+1;
16472 22989 tempffc.txsz = (tempbyte>>6)+1;
16473
16474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16475 {
16476 return qe_invalid;
16477 }
16478
16479 22989 tempffc.hit_height = (tempbyte&0x3F)+1;
16480 22989 tempffc.tysz = (tempbyte>>6)+1;
16481
16482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.flags),f))
16483 {
16484 return qe_invalid;
16485 }
16486 22989 }
16487 else
16488 {
16489 tempffc.hit_width=16;
16490 tempffc.hit_height=16;
16491 tempffc.txsz=1;
16492 tempffc.tysz=1;
16493 tempffc.flags=0;
16494 }
16495
16496 22989 tempffc.updateSolid();
16497
16498
16499
4/6
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20969 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20969 times.
22989 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16500 {
16501 tempffc.flags|=ffIGNOREHOLDUP;
16502 }
16503
16504
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>9)
16505 {
16506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.script),f))
16507 {
16508 return qe_invalid;
16509 }
16510 22989 }
16511 else
16512 {
16513 tempffc.script=0;
16514 }
16515
16516
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>10)
16517 {
16518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[0]),f))
16519 {
16520 return qe_invalid;
16521 }
16522
16523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[1]),f))
16524 {
16525 return qe_invalid;
16526 }
16527
16528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[2]),f))
16529 {
16530 return qe_invalid;
16531 }
16532
16533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[3]),f))
16534 {
16535 return qe_invalid;
16536 }
16537
16538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[4]),f))
16539 {
16540 return qe_invalid;
16541 }
16542
16543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[5]),f))
16544 {
16545 return qe_invalid;
16546 }
16547
16548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[6]),f))
16549 {
16550 return qe_invalid;
16551 }
16552
16553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[7]),f))
16554 {
16555 return qe_invalid;
16556 }
16557
16558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16559 {
16560 return qe_invalid;
16561 }
16562
16563 22989 tempffc.inita[0]=tempbyte*10000;
16564
16565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16566 {
16567 return qe_invalid;
16568 }
16569
16570 22989 tempffc.inita[1]=tempbyte*10000;
16571 22989 }
16572 else
16573 {
16574 tempffc.inita[0] = 10000;
16575 tempffc.inita[1] = 10000;
16576 }
16577
16578
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version <= 11)
16579 {
16580 fixffcs=true;
16581 }
16582 22989 }
16583 4909056 }
16584
2/2
✓ Branch 0 taken 14727168 times.
✓ Branch 1 taken 153408 times.
14880576 for(m = 32; m < MAXFFCS; ++m)
16585 {
16586 14727168 temp_mapscr->ffcs[m].clear();
16587 14727168 }
16588 153408 }
16589
16590 //add in the new whistle flags
16591
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version<13)
16592 {
16593
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 93749 times.
93768 if(temp_mapscr->flags & fWHISTLE)
16594 {
16595 19 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16596 19 }
16597 93768 }
16598
16599 //2.55 starts here
16600
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 19 && Header->zelda_version > 0x253 )
16601 {
16602
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16603 {
16604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16605 {
16606 return qe_invalid;
16607 }
16608 137360 }
16609
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16610 {
16611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16612 {
16613 return qe_invalid;
16614 }
16615 137360 }
16616
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16617 {
16618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16619 {
16620 return qe_invalid;
16621 }
16622 137360 }
16623
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16624 {
16625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16626 {
16627 return qe_invalid;
16628 }
16629 137360 }
16630 13736 }
16631
3/4
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 233440 times.
247176 if ( version < 19 && Header->zelda_version > 0x253 )
16632 {
16633 for ( int32_t q = 0; q < 10; q++ )
16634 {
16635 temp_mapscr->npcstrings[q] = 0;
16636 temp_mapscr->new_items[q] = 0;
16637 temp_mapscr->new_item_x[q] = 0;
16638 temp_mapscr->new_item_y[q] = 0;
16639 }
16640 }
16641
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 20 && Header->zelda_version > 0x253 )
16642 {
16643
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f))
16644 {
16645 return qe_invalid;
16646 }
16647
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16648 {
16649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16650 {
16651 return qe_invalid;
16652 }
16653 109888 }
16654 13736 }
16655
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
247176 if ( version < 20 )
16656 {
16657 233440 temp_mapscr->script = 0;
16658
2/2
✓ Branch 0 taken 1867520 times.
✓ Branch 1 taken 233440 times.
2100960 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16659 233440 }
16660
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 21 && Header->zelda_version > 0x253 )
16661 {
16662
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f))
16663 {
16664 return qe_invalid;
16665 }
16666 13736 }
16667
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 21 )
16668 {
16669 233440 temp_mapscr->preloadscript = 0;
16670 233440 }
16671 //all builds with version > 20 need this. -Z
16672
16673
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16674 {
16675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16676 {
16677 return qe_invalid;
16678 }
16679
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16680 {
16681 return qe_invalid;
16682 }
16683 13736 }
16684
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 22 )
16685 {
16686 233440 temp_mapscr->hidelayers = 0;
16687 233440 temp_mapscr->hidescriptlayers = 0;
16688 233440 }
16689
16690 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16691 //May be any version before 2.11. -Z
16692 /* --not the roar, the HIT SFX
16693 if ( Header->zelda_version <= 0x210 )
16694 {
16695 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16696 {
16697 temp_mapscr->bosssfx = WAV_ROAR;
16698 }
16699 }
16700 */
16701
16702 247176 return 0;
16703 247176 }
16704 257376 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version, int scrind)
16705 {
16706
2/2
✓ Branch 0 taken 247176 times.
✓ Branch 1 taken 10200 times.
257376 if(version < 23)
16707 {
16708 247176 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(ret) return ret;
16710 247176 }
16711 else
16712 {
16713
1/2
✓ Branch 0 taken 10200 times.
✗ Branch 1 not taken.
10200 if(!p_getc(&(temp_mapscr->valid),f))
16714 return qe_invalid;
16715
2/2
✓ Branch 0 taken 8487 times.
✓ Branch 1 taken 1713 times.
10200 if(!(temp_mapscr->valid & mVALID))
16716 {
16717 8487 int map = scrind/MAPSCRS;
16718 8487 int scr = scrind%MAPSCRS;
16719
4/6
✓ Branch 0 taken 6808 times.
✓ Branch 1 taken 1679 times.
✓ Branch 2 taken 6808 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6808 times.
✗ Branch 5 not taken.
8487 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16720 {
16721 //Empty screen, apply autolayers
16722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6808 times.
6808 for(int q = 0; q < 6; ++q)
16723 {
16724 auto layermap = map_autolayers[map*6+q];
16725 temp_mapscr->layermap[q] = layermap;
16726 if(layermap)
16727 temp_mapscr->layerscreen[q] = scr;
16728 }
16729 6808 }
16730 8487 return 0;
16731 }
16732 uint32_t scr_has_flags;
16733
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(!p_igetl(&scr_has_flags,f))
16734 return qe_invalid;
16735
16736
2/2
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 838 times.
1713 if(scr_has_flags & SCRHAS_ROOMDATA)
16737 {
16738
1/2
✓ Branch 0 taken 838 times.
✗ Branch 1 not taken.
838 if(!p_getc(&(temp_mapscr->guy),f))
16739 return qe_invalid;
16740
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 30 times.
838 if(version > 26)
16741 {
16742
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_igetl(&(temp_mapscr->guytile),f))
16743 return qe_invalid;
16744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if(!p_getc(&(temp_mapscr->guycs),f))
16745 return qe_invalid;
16746
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_igetw(&(temp_mapscr->roomflags),f))
16747 return qe_invalid;
16748 808 }
16749 else
16750 {
16751 30 temp_mapscr->guytile = -1; //signal to use default guy values
16752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16753
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16754 }
16755
1/2
✓ Branch 0 taken 838 times.
✗ Branch 1 not taken.
838 if(!p_igetw(&(temp_mapscr->str),f))
16756 return qe_invalid;
16757
1/2
✓ Branch 0 taken 838 times.
✗ Branch 1 not taken.
838 if(!p_getc(&(temp_mapscr->room),f))
16758 return qe_invalid;
16759
1/2
✓ Branch 0 taken 838 times.
✗ Branch 1 not taken.
838 if(!p_igetw(&(temp_mapscr->catchall),f))
16760 return qe_invalid;
16761 838 }
16762
2/2
✓ Branch 0 taken 1665 times.
✓ Branch 1 taken 48 times.
1713 if(scr_has_flags & SCRHAS_ITEM)
16763 {
16764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!p_getc(&(temp_mapscr->item),f))
16765 return qe_invalid;
16766
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_getc(&(temp_mapscr->hasitem),f))
16767 return qe_invalid;
16768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!p_getc(&(temp_mapscr->itemx),f))
16769 return qe_invalid;
16770
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_getc(&(temp_mapscr->itemy),f))
16771 return qe_invalid;
16772 48 }
16773
2/2
✓ Branch 0 taken 1587 times.
✓ Branch 1 taken 126 times.
1713 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16774 {
16775
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16776 return qe_invalid;
16777 126 }
16778
2/2
✓ Branch 0 taken 1637 times.
✓ Branch 1 taken 76 times.
1713 if(scr_has_flags & SCRHAS_TWARP)
16779 {
16780
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
16781 {
16782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16783 return qe_invalid;
16784 304 }
16785
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
16786 {
16787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16788 return qe_invalid;
16789 304 }
16790
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 76 times.
380 for(int32_t i=0; i<4; i++)
16791 {
16792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16793 return qe_invalid;
16794 304 }
16795
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16796 return qe_invalid;
16797 76 }
16798
2/2
✓ Branch 0 taken 1659 times.
✓ Branch 1 taken 54 times.
1713 if(scr_has_flags & SCRHAS_SWARP)
16799 {
16800
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 54 times.
270 for(int32_t i=0; i<4; i++)
16801 {
16802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16803 return qe_invalid;
16804 216 }
16805
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 54 times.
270 for(int32_t i=0; i<4; i++)
16806 {
16807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16808 return qe_invalid;
16809 216 }
16810
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 54 times.
270 for(int32_t i=0; i<4; i++)
16811 {
16812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16813 return qe_invalid;
16814 216 }
16815
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16816 return qe_invalid;
16817
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16818 return qe_invalid;
16819 54 }
16820
2/2
✓ Branch 0 taken 1499 times.
✓ Branch 1 taken 214 times.
1713 if(scr_has_flags & SCRHAS_WARPRET)
16821 {
16822
2/2
✓ Branch 0 taken 856 times.
✓ Branch 1 taken 214 times.
1070 for(int32_t i=0; i<4; i++)
16823 {
16824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 856 times.
856 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16825 return qe_invalid;
16826 856 }
16827
2/2
✓ Branch 0 taken 856 times.
✓ Branch 1 taken 214 times.
1070 for(int32_t i=0; i<4; i++)
16828 {
16829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 856 times.
856 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16830 return qe_invalid;
16831 856 }
16832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 214 times.
214 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16833 return qe_invalid;
16834
1/2
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
214 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16835 return qe_invalid;
16836 214 }
16837
2/2
✓ Branch 0 taken 1232 times.
✓ Branch 1 taken 481 times.
1713 if(scr_has_flags & SCRHAS_LAYERS)
16838 {
16839
2/2
✓ Branch 0 taken 2886 times.
✓ Branch 1 taken 481 times.
3367 for(int32_t k=0; k<6; k++)
16840 {
16841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2886 times.
2886 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16842 return qe_invalid;
16843 2886 }
16844
2/2
✓ Branch 0 taken 2886 times.
✓ Branch 1 taken 481 times.
3367 for(int32_t k=0; k<6; k++)
16845 {
16846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2886 times.
2886 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16847 return qe_invalid;
16848 2886 }
16849
2/2
✓ Branch 0 taken 2886 times.
✓ Branch 1 taken 481 times.
3367 for(int32_t k=0; k<6; k++)
16850 {
16851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2886 times.
2886 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16852 return qe_invalid;
16853 2886 }
16854
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(!p_getc(&(temp_mapscr->hidelayers),f))
16855 return qe_invalid;
16856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 481 times.
481 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16857 return qe_invalid;
16858 481 }
16859
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(scr_has_flags & SCRHAS_MAZE)
16860 {
16861 for(int32_t k=0; k<4; k++)
16862 {
16863 if(!p_getc(&(temp_mapscr->path[k]),f))
16864 return qe_invalid;
16865 }
16866 if(!p_getc(&(temp_mapscr->exitdir),f))
16867 return qe_invalid;
16868 }
16869
2/2
✓ Branch 0 taken 1566 times.
✓ Branch 1 taken 147 times.
1713 if(scr_has_flags & SCRHAS_D_S_U)
16870 {
16871
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16872 return qe_invalid;
16873
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 147 times.
735 for(int32_t k=0; k<4; k++)
16874 {
16875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 if(!p_getc(&(temp_mapscr->door[k]),f))
16876 return qe_invalid;
16877 588 }
16878
16879
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&(temp_mapscr->stairx),f))
16880 return qe_invalid;
16881
16882
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&(temp_mapscr->stairy),f))
16883 return qe_invalid;
16884
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_igetw(&(temp_mapscr->undercombo),f))
16885 return qe_invalid;
16886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(!p_getc(&(temp_mapscr->undercset),f))
16887 return qe_invalid;
16888 147 }
16889
2/2
✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 174 times.
1713 if(scr_has_flags & SCRHAS_FLAGS)
16890 {
16891
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_getc(&(temp_mapscr->flags),f))
16892 return qe_invalid;
16893
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_getc(&(temp_mapscr->flags2),f))
16894 return qe_invalid;
16895
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_getc(&(temp_mapscr->flags3),f))
16896 return qe_invalid;
16897
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_getc(&(temp_mapscr->flags4),f))
16898 return qe_invalid;
16899
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_getc(&(temp_mapscr->flags5),f))
16900 return qe_invalid;
16901
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_getc(&(temp_mapscr->flags6),f))
16902 return qe_invalid;
16903
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_getc(&(temp_mapscr->flags7),f))
16904 return qe_invalid;
16905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(!p_getc(&(temp_mapscr->flags8),f))
16906 return qe_invalid;
16907
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_getc(&(temp_mapscr->flags9),f))
16908 return qe_invalid;
16909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(!p_getc(&(temp_mapscr->flags10),f))
16910 return qe_invalid;
16911
1/2
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
174 if(!p_getc(&(temp_mapscr->enemyflags),f))
16912 return qe_invalid;
16913 174 }
16914
2/2
✓ Branch 0 taken 1601 times.
✓ Branch 1 taken 112 times.
1713 if(scr_has_flags & SCRHAS_ENEMY)
16915 {
16916
2/2
✓ Branch 0 taken 1120 times.
✓ Branch 1 taken 112 times.
1232 for(int32_t k=0; k<10; k++)
16917 {
16918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1120 times.
1120 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16919 return qe_invalid;
16920
1/2
✓ Branch 0 taken 1120 times.
✗ Branch 1 not taken.
1120 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
16921 temp_mapscr->enemy[k] = 0;
16922 1120 }
16923
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(!p_getc(&(temp_mapscr->pattern),f))
16924 return qe_invalid;
16925 112 }
16926
2/2
✓ Branch 0 taken 1709 times.
✓ Branch 1 taken 4 times.
1713 if(scr_has_flags & SCRHAS_CARRY)
16927 {
16928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_igetw(&(temp_mapscr->noreset),f))
16929 return qe_invalid;
16930
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&(temp_mapscr->nocarry),f))
16931 return qe_invalid;
16932
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->nextmap),f))
16933 return qe_invalid;
16934
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->nextscr),f))
16935 return qe_invalid;
16936 4 }
16937
2/2
✓ Branch 0 taken 1659 times.
✓ Branch 1 taken 54 times.
1713 if(scr_has_flags & SCRHAS_SCRIPT)
16938 {
16939
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetw(&(temp_mapscr->script),f))
16940 return qe_invalid;
16941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(!p_getc(&(temp_mapscr->preloadscript),f))
16942 return qe_invalid;
16943
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 54 times.
486 for ( int32_t q = 0; q < 8; q++ )
16944 {
16945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16946 return qe_invalid;
16947 432 }
16948 54 }
16949
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(scr_has_flags & SCRHAS_UNUSED)
16950 {
16951 for ( int32_t q = 0; q < 10; q++ )
16952 {
16953 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16954 return qe_invalid;
16955 }
16956 for ( int32_t q = 0; q < 10; q++ )
16957 {
16958 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16959 return qe_invalid;
16960 }
16961 for ( int32_t q = 0; q < 10; q++ )
16962 {
16963 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16964 return qe_invalid;
16965 }
16966 for ( int32_t q = 0; q < 10; q++ )
16967 {
16968 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16969 return qe_invalid;
16970 }
16971 }
16972
2/2
✓ Branch 0 taken 1535 times.
✓ Branch 1 taken 178 times.
1713 if(scr_has_flags & SCRHAS_SECRETS)
16973 {
16974
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 178 times.
22962 for(int32_t k=0; k<128; k++)
16975 {
16976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22784 times.
22784 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16977 return qe_invalid;
16978 22784 }
16979
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 178 times.
22962 for(int32_t k=0; k<128; k++)
16980 {
16981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22784 times.
22784 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16982 return qe_invalid;
16983 22784 }
16984
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 178 times.
22962 for(int32_t k=0; k<128; k++)
16985 {
16986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22784 times.
22784 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16987 return qe_invalid;
16988 22784 }
16989 178 }
16990
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 1291 times.
1713 if(scr_has_flags & SCRHAS_COMBOFLAG)
16991 {
16992
2/2
✓ Branch 0 taken 227216 times.
✓ Branch 1 taken 1291 times.
228507 for(int32_t k=0; k<176; ++k)
16993 {
16994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227216 times.
227216 if(!p_igetw(&(temp_mapscr->data[k]),f))
16995 return qe_invalid;
16996 227216 }
16997
2/2
✓ Branch 0 taken 227216 times.
✓ Branch 1 taken 1291 times.
228507 for(int32_t k=0; k<176; ++k)
16998 {
16999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227216 times.
227216 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17000 return qe_invalid;
17001 227216 }
17002
2/2
✓ Branch 0 taken 227216 times.
✓ Branch 1 taken 1291 times.
228507 for(int32_t k=0; k<176; ++k)
17003 {
17004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227216 times.
227216 if(!p_getc(&(temp_mapscr->cset[k]),f))
17005 return qe_invalid;
17006 227216 }
17007 1291 }
17008
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(scr_has_flags & SCRHAS_MISC)
17009 {
17010
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(!p_igetw(&(temp_mapscr->color),f))
17011 return qe_invalid;
17012
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(!p_getc(&(temp_mapscr->csensitive),f))
17013 return qe_invalid;
17014
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(!p_getc(&(temp_mapscr->oceansfx),f))
17015 return qe_invalid;
17016
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(!p_getc(&(temp_mapscr->bosssfx),f))
17017 return qe_invalid;
17018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1713 times.
1713 if(!p_getc(&(temp_mapscr->secretsfx),f))
17019 return qe_invalid;
17020
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17021 return qe_invalid;
17022
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17023 return qe_invalid;
17024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1713 times.
1713 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17025 return qe_invalid;
17026
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(!p_getc(&(temp_mapscr->lens_layer),f))
17027 return qe_invalid;
17028
2/2
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 808 times.
1713 if(version > 27)
17029 {
17030
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_getc(&(temp_mapscr->lens_show),f))
17031 return qe_invalid;
17032
1/2
✓ Branch 0 taken 808 times.
✗ Branch 1 not taken.
808 if(!p_getc(&(temp_mapscr->lens_hide),f))
17033 return qe_invalid;
17034 808 }
17035 1713 }
17036 else
17037 {
17038 temp_mapscr->screen_midi = -1;
17039 temp_mapscr->csensitive = 1;
17040 }
17041 //FFC
17042 1713 bool old_ff = version < 25;
17043 1713 dword bits = 0;
17044 1713 word numffc = 32;
17045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1713 times.
1713 if(old_ff)
17046 {
17047 if(!p_igetl(&bits,f))
17048 return qe_invalid;
17049 }
17050 else
17051 {
17052
1/2
✓ Branch 0 taken 1713 times.
✗ Branch 1 not taken.
1713 if(!p_igetw(&numffc,f))
17053 return qe_invalid;
17054 }
17055 byte tempbyte;
17056 word tempw;
17057
4/6
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32 times.
1713 static ffcdata nil_ffc;
17058 1713 temp_mapscr->ffcCountMarkDirty();
17059
2/2
✓ Branch 0 taken 1713 times.
✓ Branch 1 taken 3773 times.
5486 for(word m = 0; m < numffc; ++m)
17060 {
17061
1/2
✓ Branch 0 taken 3773 times.
✗ Branch 1 not taken.
3773 ffcdata& tempffc = (m < MAXFFCS)
17062 3773 ? temp_mapscr->ffcs[m]
17063 : nil_ffc; //sanity
17064 3773 tempffc.clear();
17065
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3773 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3773 if(old_ff && !(bits & (1<<m))) continue;
17066
17067
1/2
✓ Branch 0 taken 3773 times.
✗ Branch 1 not taken.
3773 if(!p_igetw(&tempw,f))
17068 return qe_invalid;
17069
3/4
✓ Branch 0 taken 3773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1186 times.
✓ Branch 3 taken 2587 times.
3773 if(!old_ff && !tempw) //empty ffc, nothing more to load
17070 2587 continue;
17071 1186 tempffc.setData(tempw);
17072
17073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(!p_getc(&(tempffc.cset),f))
17074 return qe_invalid;
17075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(!p_igetw(&(tempffc.delay),f))
17076 return qe_invalid;
17077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(!p_igetzf(&(tempffc.x),f))
17078 return qe_invalid;
17079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(!p_igetzf(&(tempffc.y),f))
17080 return qe_invalid;
17081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(!p_igetzf(&(tempffc.vx),f))
17082 return qe_invalid;
17083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(!p_igetzf(&(tempffc.vy),f))
17084 return qe_invalid;
17085
1/2
✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
1186 if(!p_igetzf(&(tempffc.ax),f))
17086 return qe_invalid;
17087
1/2
✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
1186 if(!p_igetzf(&(tempffc.ay),f))
17088 return qe_invalid;
17089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(!p_getc(&(tempffc.link),f))
17090 return qe_invalid;
17091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(version < 24)
17092 {
17093 if(!p_getc(&tempbyte,f))
17094 return qe_invalid;
17095 tempffc.hit_width = (tempbyte&0x3F)+1;
17096 tempffc.txsz = (tempbyte>>6)+1;
17097 if(!p_getc(&tempbyte,f))
17098 return qe_invalid;
17099 tempffc.hit_height = (tempbyte&0x3F)+1;
17100 tempffc.tysz = (tempbyte>>6)+1;
17101 }
17102 else
17103 {
17104
1/2
✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
1186 if(!p_igetl(&(tempffc.hit_width),f))
17105 return qe_invalid;
17106
1/2
✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
1186 if(!p_igetl(&(tempffc.hit_height),f))
17107 return qe_invalid;
17108
1/2
✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
1186 if(!p_getc(&(tempffc.txsz),f))
17109 return qe_invalid;
17110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(!p_getc(&(tempffc.tysz),f))
17111 return qe_invalid;
17112 }
17113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(!p_igetl(&(tempffc.flags),f))
17114 return qe_invalid;
17115 1186 tempffc.updateSolid();
17116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(!p_igetw(&(tempffc.script),f))
17117 return qe_invalid;
17118
2/2
✓ Branch 0 taken 9488 times.
✓ Branch 1 taken 1186 times.
10674 for(auto q = 0; q < 8; ++q)
17119 {
17120
1/2
✓ Branch 0 taken 9488 times.
✗ Branch 1 not taken.
9488 if(!p_igetl(&(tempffc.initd[q]),f))
17121 return qe_invalid;
17122 9488 }
17123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
1186 if(!p_getc(&(tempbyte),f))
17124 return qe_invalid;
17125 1186 tempffc.inita[0]=tempbyte*10000;
17126
17127
1/2
✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
1186 if(!p_getc(&(tempbyte),f))
17128 return qe_invalid;
17129 1186 tempffc.inita[1]=tempbyte*10000;
17130 1186 }
17131
2/2
✓ Branch 0 taken 215491 times.
✓ Branch 1 taken 1713 times.
217204 for(word m = numffc; m < MAXFFCS; ++m)
17132 {
17133 215491 temp_mapscr->ffcs[m].clear();
17134 215491 }
17135 //END FFC
17136 }
17137 248889 return 0;
17138 257376 }
17139
17140
17141 129 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17142 {
17143 129 int32_t scr=0;
17144
17145 129 word version=0;
17146 dword dummy;
17147 int32_t screens_to_read;
17148
17149 129 mapscr temp_mapscr;
17150 zcmap temp_map;
17151 word temp_map_count;
17152 dword section_size;
17153
17154
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17155 {
17156 4 screens_to_read=MAPSCRS192b136;
17157 4 }
17158 else
17159 {
17160 125 screens_to_read=MAPSCRS;
17161 }
17162
17163
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version > 0x192)
17164 {
17165 //section version info
17166
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&version,f))
17167 {
17168 return qe_invalid;
17169 }
17170
17171 125 FFCore.quest_format[vMaps] = version;
17172
17173 //al_trace("Maps version %d\n", version);
17174
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
17175 {
17176 return qe_invalid;
17177 }
17178
17179 //section size
17180
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&section_size,f))
17181 {
17182 return qe_invalid;
17183 }
17184
17185 //finally... section data
17186
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_map_count,f))
17187 {
17188 return 5;
17189 }
17190 125 }
17191 else
17192 {
17193 4 temp_map_count=map_count;
17194 }
17195
17196
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS2))
17197 {
17198 return qe_invalid;
17199 }
17200
17201 129 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17202 129 TheMaps.resize(_mapsSize);
17203 129 map_autolayers.clear();
17204 129 map_autolayers.resize(temp_map_count*6);
17205
17206
2/2
✓ Branch 0 taken 258264 times.
✓ Branch 1 taken 129 times.
258393 for(int32_t i(0); i<_mapsSize; i++)
17207 258264 TheMaps[i].zero_memory();
17208
17209 129 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17210
17211 129 temp_mapscr.zero_memory();
17212
17213 { //Is this stuff even needed anymore? Is it used at all? -Em
17214 129 memset(&temp_map, 0, sizeof(zcmap));
17215 129 temp_map.scrResWidth = 256;
17216 129 temp_map.scrResHeight = 224;
17217 129 temp_map.tileWidth = 16;
17218 129 temp_map.tileHeight = 11;
17219 129 temp_map.viewWidth = 256;
17220 129 temp_map.viewHeight = 176;
17221 129 temp_map.viewX = 0;
17222 129 temp_map.viewY = 64;
17223 129 temp_map.subaWidth = 256;
17224 129 temp_map.subaHeight = 168;
17225 129 temp_map.subaTrans = false;
17226 129 temp_map.subpWidth = 256;
17227 129 temp_map.subpHeight = 56;
17228 129 temp_map.subpTrans = false;
17229 }
17230
4/4
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 1899 times.
✓ Branch 2 taken 1899 times.
✓ Branch 3 taken 129 times.
2028 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17231 {
17232 //!TODO Trim fully
17233 1899 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17234
17235 1899 byte valid=1;
17236
2/2
✓ Branch 0 taken 1819 times.
✓ Branch 1 taken 80 times.
1899 if(version > 22)
17237 {
17238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(!p_getc(&valid,f))
17239 return qe_invalid;
17240 80 }
17241
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1838 times.
✓ Branch 3 taken 56 times.
1899 if(valid && version > 25)
17242 {
17243
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 56 times.
392 for(int q = 0; q < 6; ++q)
17244 {
17245
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetw(&map_autolayers[i*6+q],f))
17246 return qe_invalid;
17247 336 }
17248 56 }
17249
2/2
✓ Branch 0 taken 258056 times.
✓ Branch 1 taken 1899 times.
259955 for(int32_t j=0; j<screens_to_read; j++)
17250 {
17251 258056 scr=i*MAPSCRS+j;
17252 258056 clear_screen(&temp_mapscr);
17253
2/2
✓ Branch 0 taken 680 times.
✓ Branch 1 taken 257376 times.
258056 if(valid)
17254 257376 readmapscreen(f, Header, &temp_mapscr, &temp_map, version, scr);
17255
17256 258056 TheMaps[scr] = temp_mapscr;
17257 258056 }
17258
17259
3/6
✓ Branch 0 taken 1847 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1847 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1899 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17260 {
17261 52 int32_t index = (i*MAPSCRS+132);
17262
17263 52 TheMaps[index]=TheMaps[index-1];
17264
17265 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17266 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17267 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17268
17269
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17270 {
17271 156 scr=i*MAPSCRS+j;
17272
17273 156 TheMaps[scr].zero_memory();
17274 156 TheMaps[scr].valid = mVERSION;
17275 156 TheMaps[scr].screen_midi = -1;
17276 156 TheMaps[scr].csensitive = 1;
17277 156 }
17278 52 }
17279
17280
3/6
✓ Branch 0 taken 1847 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1847 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1899 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17281 {
17282
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17283 {
17284 7072 scr=i*MAPSCRS+j;
17285 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17286
17287
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17288 {
17289 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17290 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17291 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17292 905216 }
17293 7072 }
17294 52 }
17295 1899 }
17296 129 map_count = temp_map_count;
17297 129 clear_screen(&temp_mapscr);
17298 129 return 0;
17299 129 }
17300
17301
17302 1083413 void update_combo(newcombo& cmb, word section_version)
17303 {
17304
2/2
✓ Branch 0 taken 158844 times.
✓ Branch 1 taken 924569 times.
1083413 if(section_version < 40)
17305 {
17306
3/3
✓ Branch 0 taken 1358 times.
✓ Branch 1 taken 14128 times.
✓ Branch 2 taken 909083 times.
924569 switch(cmb.type)
17307 {
17308 case cWATER: case cSHALLOWWATER:
17309 14128 cmb.attribytes[6] = iwRipples;
17310 14128 break;
17311 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17312 1358 cmb.attribytes[6] = iwTallGrass;
17313 1358 break;
17314 }
17315 924569 }
17316 1083413 }
17317 95 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17318 {
17319 95 reset_combo_animations();
17320 95 reset_combo_animations2();
17321
17322 95 init_combo_classes();
17323
17324 // combos
17325 95 word combos_used=0;
17326 int32_t dummy;
17327 byte padding;
17328 95 newcombo temp_combo;
17329 //word section_cversion=0;
17330
17331
2/2
✓ Branch 0 taken 6201600 times.
✓ Branch 1 taken 95 times.
6201695 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17332
1/2
✓ Branch 0 taken 6201600 times.
✗ Branch 1 not taken.
6201600 combobuf[q].clear();
17333
17334 // if(version > 0x192)
17335 // {
17336 // //section version info
17337 // if(!p_igetw(&section_version,f))
17338 // {
17339 // return qe_invalid;
17340 // }
17341
17342 // FFCore.quest_format[vCombos] = section_version;
17343
17344 // //al_trace("Combos version %d\n", section_version);
17345 // if(!p_igetw(&section_cversion,f))
17346 // {
17347 // return qe_invalid;
17348 // }
17349
17350 // //section size
17351 // if(!p_igetl(&dummy,f))
17352 // {
17353 // return qe_invalid;
17354 // }
17355 // }
17356
17357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(version < 0x174)
17358 {
17359 combos_used=1024;
17360 }
17361
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 else if(version < 0x191)
17362 {
17363 4 combos_used=2048;
17364 4 }
17365 else
17366 {
17367
2/4
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
91 if(!p_igetw(&combos_used,f))
17368 {
17369 return qe_invalid;
17370 }
17371 }
17372
17373 //finally... section data
17374
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 873209 times.
873304 for(int32_t i=0; i<combos_used; i++)
17375 {
17376
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 temp_combo.clear();
17377
17378
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if ( section_version >= 11 )
17379 {
17380
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f))
17381 {
17382 return qe_invalid;
17383 }
17384 68884 }
17385 else
17386 {
17387
2/4
✓ Branch 0 taken 804325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804325 times.
✗ Branch 3 not taken.
804325 if(!p_igetw(&temp_combo.tile,f))
17388 {
17389 return qe_invalid;
17390 }
17391 }
17392 873209 temp_combo.o_tile = temp_combo.tile;
17393
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.flip,f))
17394 {
17395 return qe_invalid;
17396 }
17397
17398
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.walk,f))
17399 {
17400 return qe_invalid;
17401 }
17402
17403
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.type,f))
17404 {
17405 return qe_invalid;
17406 }
17407
17408
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.csets,f))
17409 {
17410 return qe_invalid;
17411 }
17412
17413
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 865017 times.
873209 if(version < 0x193)
17414 {
17415
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17416 return qe_invalid;
17417
17418
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17419 return qe_invalid;
17420
17421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17422 {
17423
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17424 {
17425 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17426 {
17427 if(!p_getc(&padding,f))
17428 return qe_invalid;
17429 }
17430 }
17431 8192 }
17432 8192 }
17433
2/2
✓ Branch 0 taken 865017 times.
✓ Branch 1 taken 8192 times.
873209 if(version >= 0x192)
17434 {
17435
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.frames,f))
17436 return qe_invalid;
17437
17438
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.speed,f))
17439 return qe_invalid;
17440
17441
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_igetw(&temp_combo.nextcombo,f))
17442 return qe_invalid;
17443
17444
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.nextcset,f))
17445 return qe_invalid;
17446
17447 //Base flag
17448
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=3)
17449
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.flag,f))
17450 return qe_invalid;
17451
17452
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=4)
17453 {
17454
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanim,f))
17455 return qe_invalid;
17456
17457
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_igetw(&temp_combo.nexttimer,f))
17458 return qe_invalid;
17459 399183 }
17460
17461
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=5)
17462
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanimy,f))
17463 return qe_invalid;
17464
17465
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=6)
17466 {
17467
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.animflags,f))
17468 return qe_invalid;
17469
17470
1/2
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
399183 if(section_version == 6)
17471 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17472 399183 }
17473
17474
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=8) //combo Attributes[4] and userflags.
17475 {
17476
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17477
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f))
17478 return qe_invalid;
17479
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f))
17480 return qe_invalid;
17481
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17482
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f))
17483 return qe_invalid;
17484 68884 }
17485
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=10) //combo trigger flags
17486 {
17487
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17488
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f))
17489 return qe_invalid;
17490 68884 }
17491
1/2
✓ Branch 0 taken 796133 times.
✗ Branch 1 not taken.
796133 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17492 {
17493 for ( int32_t q = 0; q < 2; q++ )
17494 if(!p_igetl(&temp_combo.triggerflags[q],f))
17495 return qe_invalid;
17496 }
17497
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 9)
17498
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f))
17499 return qe_invalid;
17500
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 22)
17501
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f))
17502 return qe_invalid;
17503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 24)
17504 {
17505 if(!p_getc(&temp_combo.triggeritem,f))
17506 return qe_invalid;
17507 if(!p_getc(&temp_combo.trigtimer,f))
17508 return qe_invalid;
17509 }
17510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 25)
17511 if(!p_getc(&temp_combo.trigsfx,f))
17512 return qe_invalid;
17513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 27)
17514 if(!p_igetl(&temp_combo.trigchange,f))
17515 return qe_invalid;
17516
17517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 29)
17518 {
17519 if(!p_igetw(&temp_combo.trigprox,f))
17520 return qe_invalid;
17521 if(!p_getc(&temp_combo.trigctr,f))
17522 return qe_invalid;
17523 if(!p_igetl(&temp_combo.trigctramnt,f))
17524 return qe_invalid;
17525 }
17526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 30)
17527 if(!p_getc(&temp_combo.triglbeam,f))
17528 return qe_invalid;
17529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 31)
17530 {
17531 if(!p_getc(&temp_combo.trigcschange,f))
17532 return qe_invalid;
17533 if(!p_igetw(&temp_combo.spawnitem,f))
17534 return qe_invalid;
17535 if(!p_igetw(&temp_combo.spawnenemy,f))
17536 return qe_invalid;
17537 if(!p_getc(&temp_combo.exstate,f))
17538 return qe_invalid;
17539 if(!p_igetl(&temp_combo.spawnip,f))
17540 return qe_invalid;
17541 if(!p_getc(&temp_combo.trigcopycat,f))
17542 return qe_invalid;
17543 }
17544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 32)
17545 if(!p_getc(&temp_combo.trigcooldown,f))
17546 return qe_invalid;
17547
17548
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=12) //combo label
17549 {
17550 char label[12];
17551 68884 label[11] = '\0';
17552
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17553
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f))
17554 return qe_invalid;
17555
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17556 68884 }
17557
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=13) //attribytes[4]
17558
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17559
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17560 68884 return qe_invalid;
17561 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17562 * This fixes a poor implementation of a ->next flag bug thing.
17563 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17564 * there was a version bump a few weeks before a change that broke stuff.
17565 */
17566
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
865017 if (section_version >= 13 && section_version < 21)
17567 {
17568 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17569 }
17570 //combo scripts
17571
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=14)
17572 {
17573
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f))
17574 return qe_invalid;
17575
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17576
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f))
17577 return qe_invalid;
17578 68884 }
17579 //al_trace("Read combo script data\n");
17580
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=15)
17581 {
17582
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17583
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17584
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17585
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17586 68884 }
17587
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=17) //attribytes[4]
17588 {
17589
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17590
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17591 return qe_invalid;
17592
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17593
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f))
17594 return qe_invalid;
17595 68884 }
17596
17597
1/2
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
865017 if(version < 0x193)
17598 for(int32_t q=0; q<11; q++)
17599 if(!p_getc(&dummy,f))
17600 return qe_invalid;
17601 865017 }
17602
17603 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17604
3/6
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 474026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399183 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
873209 if((version < 0x211)||((version == 0x211)&&(build<7)))
17605 {
17606
3/4
✓ Branch 0 taken 474026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 465834 times.
✓ Branch 3 taken 8192 times.
474026 if(!get_qr(qr_NEWENEMYTILES))
17607 {
17608
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17609 {
17610 case 130:
17611 temp_combo.tile = 132;
17612 break;
17613
17614 case 131:
17615 temp_combo.tile = 133;
17616 break;
17617
17618 case 132:
17619 temp_combo.tile = 130;
17620 break;
17621
17622 case 133:
17623 temp_combo.tile = 131;
17624 break;
17625 }
17626 8192 }
17627 474026 }
17628
17629
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 15)
17630 804325 temp_combo.o_tile = temp_combo.tile;
17631
17632
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version<18) //upper bits for .walk
17633 804325 temp_combo.walk |= 0xF0;
17634
17635
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 19)
17636
2/2
✓ Branch 0 taken 3217300 times.
✓ Branch 1 taken 804325 times.
4021625 for(int32_t q = 0; q < 4; ++q)
17637 4021625 temp_combo.attributes[q] *= 10000L;
17638
17639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 23)
17640 {
17641
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 872825 times.
873209 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17642 {
17643 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17644 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17645 case cTRIGGERGENERIC: case cCSWITCH:
17646 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17647 384 }
17648 873209 }
17649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 25)
17650 {
17651
2/2
✓ Branch 0 taken 3061 times.
✓ Branch 1 taken 870148 times.
873209 switch(temp_combo.type)
17652 {
17653 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061 times.
3061 if(!(temp_combo.usrflags & cflag3))
17655 3061 temp_combo.attribytes[3] = WAV_DOOR;
17656 3061 temp_combo.usrflags &= ~cflag3;
17657 3061 break;
17658 }
17659 873209 }
17660
17661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 26)
17662
2/2
✓ Branch 0 taken 872622 times.
✓ Branch 1 taken 587 times.
873796 if(temp_combo.type == cARMOS)
17663
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(temp_combo.usrflags & cflag1)
17664 temp_combo.usrflags |= cflag3;
17665
17666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 27)
17667 {
17668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17669 temp_combo.trigchange = 1;
17670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17671 temp_combo.trigchange = -1;
17672 873209 else temp_combo.trigchange = 0;
17673 873209 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17674 873209 }
17675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 28)
17676 {
17677
2/2
✓ Branch 0 taken 1689 times.
✓ Branch 1 taken 871520 times.
873209 switch(temp_combo.type)
17678 {
17679 case cLOCKBLOCK: case cLOCKEDCHEST:
17680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1689 times.
1689 if(temp_combo.usrflags & cflag7)
17681 temp_combo.usrflags |= cflag8;
17682 1689 else temp_combo.usrflags &= ~cflag8;
17683 1689 temp_combo.usrflags &= ~cflag7;
17684 1689 break;
17685 }
17686
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 873140 times.
873209 switch(temp_combo.type)
17687 {
17688 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17689 69 temp_combo.attrishorts[2] = -1;
17690 69 temp_combo.usrflags |= cflag7;
17691 69 break;
17692 }
17693 873209 }
17694
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 20)
17695 {
17696 804325 temp_combo.genflags = 0;
17697
2/2
✓ Branch 0 taken 19291 times.
✓ Branch 1 taken 785034 times.
804325 switch(temp_combo.type)
17698 {
17699 case cPUSH_WAIT: case cPUSH_HEAVY:
17700 case cPUSH_HW: case cL_STATUE:
17701 case cR_STATUE: case cPUSH_HEAVY2:
17702 case cPUSH_HW2: case cPOUND:
17703 case cC_STATUE: case cMIRROR:
17704 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17705 case cMAGICPRISM: case cMAGICPRISM4:
17706 case cMAGICSPONGE: case cEYEBALL_A:
17707 case cEYEBALL_B: case cEYEBALL_4:
17708 case cBUSH: case cFLOWERS:
17709 case cLOCKBLOCK: case cLOCKBLOCK2:
17710 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17711 case cCHEST: case cCHEST2:
17712 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17713 case cBOSSCHEST: case cBOSSCHEST2:
17714 case cBUSHNEXT: case cBUSHTOUCHY:
17715 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17716 case cSIGNPOST: case cCSWITCHBLOCK:
17717 case cTORCH: case cTRIGGERGENERIC:
17718
1/2
✓ Branch 0 taken 19291 times.
✗ Branch 1 not taken.
19291 if(temp_combo.usrflags & cflag16)
17719 {
17720 temp_combo.genflags |= cflag1;
17721 temp_combo.usrflags &= ~cflag16;
17722 }
17723 19291 break;
17724 }
17725 804325 }
17726
17727 873209 update_combo(temp_combo, section_version);
17728
17729
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 if(i>=start_combo)
17730 {
17731
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 combobuf[i] = temp_combo;
17732 873209 }
17733 873209 }
17734
17735
3/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
95 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17736 {
17737
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17738 {
17739
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17740 {
17741 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17742 }
17743 261120 }
17744 4 }
17745
17746 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17747
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
95 if(version == 0x210 && !is_zquest())
17748 {
17749
2/2
✓ Branch 0 taken 783360 times.
✓ Branch 1 taken 12 times.
783372 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17750
2/2
✓ Branch 0 taken 783351 times.
✓ Branch 1 taken 9 times.
783369 if(combobuf[tmpcounter].type == cLADDERONLY)
17751 9 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17752 12 }
17753
17754
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<7)
17755 {
17756
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 16 times.
1044496 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17757 {
17758
6/9
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1043840 times.
1044480 switch(combobuf[tmpcounter].type)
17759 {
17760 case cSLASH:
17761 250 combobuf[tmpcounter].type=cSLASHTOUCHY;
17762 250 break;
17763
17764 case cSLASHITEM:
17765 174 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17766 174 break;
17767
17768 case cBUSH:
17769 126 combobuf[tmpcounter].type=cBUSHTOUCHY;
17770 126 break;
17771
17772 case cFLOWERS:
17773 45 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17774 45 break;
17775
17776 case cTALLGRASS:
17777 45 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17778 45 break;
17779
17780 case cSLASHNEXT:
17781 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17782 break;
17783
17784 case cSLASHNEXTITEM:
17785 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17786 break;
17787
17788 case cBUSHNEXT:
17789 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17790 break;
17791 }
17792 1044480 }
17793 16 }
17794
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 93 times.
95 if (section_version < 16)
17795 {
17796
2/2
✓ Branch 0 taken 6071040 times.
✓ Branch 1 taken 93 times.
6071133 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17797 {
17798
2/2
✓ Branch 0 taken 6062986 times.
✓ Branch 1 taken 8054 times.
6071040 if (combobuf[tmpcounter].type == cWATER)
17799 {
17800 8054 combobuf[tmpcounter].attributes[0] = 40000L;
17801 8054 }
17802 6071040 }
17803 93 }
17804
3/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 1 times.
95 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17805 {
17806 1 combobuf[0].walk = 0xF0;
17807 1 combobuf[0].type = 0;
17808 1 combobuf[0].flag = 0;
17809 1 }
17810
17811 //Now for the new combo alias reset
17812
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<2)
17813 {
17814
2/2
✓ Branch 0 taken 131072 times.
✓ Branch 1 taken 16 times.
131088 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17815 {
17816 131072 combo_aliases[j].width = 0;
17817 131072 combo_aliases[j].height = 0;
17818 131072 combo_aliases[j].layermask = 0;
17819
17820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].combos != NULL)
17821 {
17822
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].combos;
17823 131072 }
17824
17825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].csets != NULL)
17826 {
17827
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].csets;
17828 131072 }
17829
17830
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].combos = new word[1];
17831
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].csets = new byte[1];
17832 131072 combo_aliases[j].combos[0] = 0;
17833 131072 combo_aliases[j].csets[0] = 0;
17834 131072 }
17835 16 }
17836
17837
17838
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations();
17839
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations2();
17840 95 return 0;
17841 95 }
17842 210204 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17843 {
17844 byte combo_has_flags;
17845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210204 times.
210204 if(!p_getc(&combo_has_flags,f))
17846 return qe_invalid;
17847
17848 210204 temp_combo.clear();
17849
2/2
✓ Branch 0 taken 141991 times.
✓ Branch 1 taken 68213 times.
210204 if(combo_has_flags)
17850 {
17851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68213 times.
68213 if(combo_has_flags&CHAS_BASIC)
17852 {
17853
1/2
✓ Branch 0 taken 68213 times.
✗ Branch 1 not taken.
68213 if(!p_igetl(&temp_combo.tile,f))
17854 {
17855 return qe_invalid;
17856 }
17857 68213 temp_combo.o_tile = temp_combo.tile;
17858
17859
1/2
✓ Branch 0 taken 68213 times.
✗ Branch 1 not taken.
68213 if(!p_getc(&temp_combo.flip,f))
17860 {
17861 return qe_invalid;
17862 }
17863
17864
1/2
✓ Branch 0 taken 68213 times.
✗ Branch 1 not taken.
68213 if(!p_getc(&temp_combo.walk,f))
17865 {
17866 return qe_invalid;
17867 }
17868
17869
1/2
✓ Branch 0 taken 68213 times.
✗ Branch 1 not taken.
68213 if(!p_getc(&temp_combo.type,f))
17870 {
17871 return qe_invalid;
17872 }
17873
17874
1/2
✓ Branch 0 taken 68213 times.
✗ Branch 1 not taken.
68213 if(!p_getc(&temp_combo.flag,f))
17875 {
17876 return qe_invalid;
17877 }
17878
17879
1/2
✓ Branch 0 taken 68213 times.
✗ Branch 1 not taken.
68213 if(!p_getc(&temp_combo.csets,f))
17880 {
17881 return qe_invalid;
17882 }
17883 68213 }
17884
2/2
✓ Branch 0 taken 68205 times.
✓ Branch 1 taken 8 times.
68213 if(combo_has_flags&CHAS_SCRIPT)
17885 {
17886
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (s_version>=41)
17887 {
17888 8 p_getcstr(&temp_combo.label, f);
17889 8 }
17890 else
17891 {
17892 char label[12];
17893 label[11] = '\0';
17894 for ( int32_t q = 0; q < 11; q++ )
17895 {
17896 if(!p_getc(&label[q],f))
17897 {
17898 return qe_invalid;
17899 }
17900 }
17901 temp_combo.label = label;
17902 }
17903
17904
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17905 8 auto initd_count = s_version >= 43 ? 8 : 2;
17906
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 8 times.
72 for ( int32_t q = 0; q < initd_count; q++ )
17907 {
17908
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_igetl(&temp_combo.initd[q],f))
17909 {
17910 return qe_invalid;
17911 }
17912 64 }
17913 8 }
17914
2/2
✓ Branch 0 taken 52418 times.
✓ Branch 1 taken 15795 times.
68213 if(combo_has_flags&CHAS_ANIM)
17915 {
17916
1/2
✓ Branch 0 taken 15795 times.
✗ Branch 1 not taken.
15795 if(!p_getc(&temp_combo.frames,f))
17917 {
17918 return qe_invalid;
17919 }
17920
17921
1/2
✓ Branch 0 taken 15795 times.
✗ Branch 1 not taken.
15795 if(!p_getc(&temp_combo.speed,f))
17922 {
17923 return qe_invalid;
17924 }
17925
17926
1/2
✓ Branch 0 taken 15795 times.
✗ Branch 1 not taken.
15795 if(!p_igetw(&temp_combo.nextcombo,f))
17927 {
17928 return qe_invalid;
17929 }
17930
17931
1/2
✓ Branch 0 taken 15795 times.
✗ Branch 1 not taken.
15795 if(!p_getc(&temp_combo.nextcset,f))
17932 {
17933 return qe_invalid;
17934 }
17935
17936
1/2
✓ Branch 0 taken 15795 times.
✗ Branch 1 not taken.
15795 if(!p_getc(&temp_combo.skipanim,f))
17937 {
17938 return qe_invalid;
17939 }
17940
17941
1/2
✓ Branch 0 taken 15795 times.
✗ Branch 1 not taken.
15795 if(!p_getc(&temp_combo.skipanimy,f))
17942 {
17943 return qe_invalid;
17944 }
17945
17946
1/2
✓ Branch 0 taken 15795 times.
✗ Branch 1 not taken.
15795 if(!p_getc(&temp_combo.animflags,f))
17947 {
17948 return qe_invalid;
17949 }
17950 15795 }
17951
2/2
✓ Branch 0 taken 57860 times.
✓ Branch 1 taken 10353 times.
68213 if(combo_has_flags&CHAS_ATTRIB)
17952 {
17953
2/2
✓ Branch 0 taken 41412 times.
✓ Branch 1 taken 10353 times.
51765 for ( int32_t q = 0; q < 4; q++ )
17954 {
17955
1/2
✓ Branch 0 taken 41412 times.
✗ Branch 1 not taken.
41412 if(!p_igetl(&temp_combo.attributes[q],f))
17956 {
17957 return qe_invalid;
17958 }
17959 41412 }
17960
2/2
✓ Branch 0 taken 82824 times.
✓ Branch 1 taken 10353 times.
93177 for ( int32_t q = 0; q < 8; q++ )
17961 {
17962
1/2
✓ Branch 0 taken 82824 times.
✗ Branch 1 not taken.
82824 if(!p_getc(&temp_combo.attribytes[q],f))
17963 {
17964 return qe_invalid;
17965 }
17966 82824 }
17967
2/2
✓ Branch 0 taken 82824 times.
✓ Branch 1 taken 10353 times.
93177 for ( int32_t q = 0; q < 8; q++ )
17968 {
17969
1/2
✓ Branch 0 taken 82824 times.
✗ Branch 1 not taken.
82824 if(!p_igetw(&temp_combo.attrishorts[q],f))
17970 {
17971 return qe_invalid;
17972 }
17973 82824 }
17974 10353 }
17975
2/2
✓ Branch 0 taken 66111 times.
✓ Branch 1 taken 2102 times.
68213 if(combo_has_flags&CHAS_FLAG)
17976 {
17977
1/2
✓ Branch 0 taken 2102 times.
✗ Branch 1 not taken.
2102 if(!p_igetl(&temp_combo.usrflags,f))
17978 {
17979 return qe_invalid;
17980 }
17981
1/2
✓ Branch 0 taken 2102 times.
✗ Branch 1 not taken.
2102 if(!p_igetw(&temp_combo.genflags,f))
17982 {
17983 return qe_invalid;
17984 }
17985 2102 }
17986
2/2
✓ Branch 0 taken 67478 times.
✓ Branch 1 taken 735 times.
68213 if(combo_has_flags&CHAS_TRIG)
17987 {
17988 735 int numtrigs = s_version < 36 ? 3 : 6;
17989
2/2
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 735 times.
4887 for ( int32_t q = 0; q < numtrigs; q++ )
17990 {
17991
1/2
✓ Branch 0 taken 4152 times.
✗ Branch 1 not taken.
4152 if(!p_igetl(&temp_combo.triggerflags[q],f))
17992 {
17993 return qe_invalid;
17994 }
17995 4152 }
17996
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_igetl(&temp_combo.triggerlevel,f))
17997 {
17998 return qe_invalid;
17999 }
18000
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_getc(&temp_combo.triggerbtn,f))
18001 {
18002 return qe_invalid;
18003 }
18004
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_getc(&temp_combo.triggeritem,f))
18005 {
18006 return qe_invalid;
18007 }
18008
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_getc(&temp_combo.trigtimer,f))
18009 {
18010 return qe_invalid;
18011 }
18012
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_getc(&temp_combo.trigsfx,f))
18013 {
18014 return qe_invalid;
18015 }
18016
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_igetl(&temp_combo.trigchange,f))
18017 {
18018 return qe_invalid;
18019 }
18020
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_igetw(&temp_combo.trigprox,f))
18021 {
18022 return qe_invalid;
18023 }
18024
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_getc(&temp_combo.trigctr,f))
18025 {
18026 return qe_invalid;
18027 }
18028
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_igetl(&temp_combo.trigctramnt,f))
18029 {
18030 return qe_invalid;
18031 }
18032
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_getc(&temp_combo.triglbeam,f))
18033 {
18034 return qe_invalid;
18035 }
18036
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_getc(&temp_combo.trigcschange,f))
18037 {
18038 return qe_invalid;
18039 }
18040
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_igetw(&temp_combo.spawnitem,f))
18041 {
18042 return qe_invalid;
18043 }
18044
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_igetw(&temp_combo.spawnenemy,f))
18045 {
18046 return qe_invalid;
18047 }
18048
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_getc(&temp_combo.exstate,f))
18049 {
18050 return qe_invalid;
18051 }
18052
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_igetl(&temp_combo.spawnip,f))
18053 {
18054 return qe_invalid;
18055 }
18056
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_getc(&temp_combo.trigcopycat,f))
18057 {
18058 return qe_invalid;
18059 }
18060
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_getc(&temp_combo.trigcooldown,f))
18061 {
18062 return qe_invalid;
18063 }
18064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 735 times.
735 if(s_version >= 35)
18065 {
18066
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_igetw(&temp_combo.prompt_cid,f))
18067 {
18068 return qe_invalid;
18069 }
18070
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_getc(&temp_combo.prompt_cs,f))
18071 {
18072 return qe_invalid;
18073 }
18074
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_igetw(&temp_combo.prompt_x,f))
18075 {
18076 return qe_invalid;
18077 }
18078
1/2
✓ Branch 0 taken 735 times.
✗ Branch 1 not taken.
735 if(!p_igetw(&temp_combo.prompt_y,f))
18079 {
18080 return qe_invalid;
18081 }
18082 735 }
18083
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 649 times.
735 if(s_version >= 36)
18084 {
18085
1/2
✓ Branch 0 taken 649 times.
✗ Branch 1 not taken.
649 if(!p_getc(&temp_combo.trig_lstate,f))
18086 {
18087 return qe_invalid;
18088 }
18089
1/2
✓ Branch 0 taken 649 times.
✗ Branch 1 not taken.
649 if(!p_getc(&temp_combo.trig_gstate,f))
18090 {
18091 return qe_invalid;
18092 }
18093
1/2
✓ Branch 0 taken 649 times.
✗ Branch 1 not taken.
649 if(!p_igetl(&temp_combo.trig_statetime,f))
18094 {
18095 return qe_invalid;
18096 }
18097 649 }
18098
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 649 times.
735 if(s_version >= 37)
18099 {
18100
1/2
✓ Branch 0 taken 649 times.
✗ Branch 1 not taken.
649 if(!p_igetw(&temp_combo.trig_genscr,f))
18101 {
18102 return qe_invalid;
18103 }
18104 649 }
18105
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 575 times.
735 if(s_version >= 38)
18106 {
18107
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(!p_getc(&temp_combo.trig_group,f))
18108 {
18109 return qe_invalid;
18110 }
18111
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(!p_igetw(&temp_combo.trig_group_val,f))
18112 {
18113 return qe_invalid;
18114 }
18115 575 }
18116 735 }
18117
2/2
✓ Branch 0 taken 68066 times.
✓ Branch 1 taken 147 times.
68213 if(combo_has_flags&CHAS_LIFT)
18118 {
18119
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_igetw(&temp_combo.liftcmb,f))
18120 return qe_invalid;
18121
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftcs,f))
18122 return qe_invalid;
18123
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_igetw(&temp_combo.liftundercmb,f))
18124 return qe_invalid;
18125
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftundercs,f))
18126 return qe_invalid;
18127
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftdmg,f))
18128 return qe_invalid;
18129
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftlvl,f))
18130 return qe_invalid;
18131
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftitm,f))
18132 return qe_invalid;
18133
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftflags,f))
18134 return qe_invalid;
18135
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftgfx,f))
18136 return qe_invalid;
18137
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftsprite,f))
18138 return qe_invalid;
18139
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftsfx,f))
18140 return qe_invalid;
18141
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18142 return qe_invalid;
18143
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.liftbreaksfx,f))
18144 return qe_invalid;
18145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(s_version >= 34)
18146 {
18147
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.lifthei,f))
18148 return qe_invalid;
18149
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if(!p_getc(&temp_combo.lifttime,f))
18150 return qe_invalid;
18151 147 }
18152
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 140 times.
147 if(s_version >= 39)
18153 {
18154
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(!p_getc(&temp_combo.lift_parent_item,f))
18155 return qe_invalid;
18156 140 }
18157 147 }
18158
2/2
✓ Branch 0 taken 68117 times.
✓ Branch 1 taken 96 times.
68213 if(combo_has_flags&CHAS_GENERAL)
18159 {
18160
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.speed_mult,f))
18161 return qe_invalid;
18162
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.speed_div,f))
18163 return qe_invalid;
18164
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetzf(&temp_combo.speed_add,f))
18165 return qe_invalid;
18166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version >= 42)
18167 {
18168
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.sfx_appear,f))
18169 return qe_invalid;
18170
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.sfx_disappear,f))
18171 return qe_invalid;
18172
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.sfx_loop,f))
18173 return qe_invalid;
18174
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.sfx_walking,f))
18175 return qe_invalid;
18176
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.sfx_standing,f))
18177 return qe_invalid;
18178
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.spr_appear,f))
18179 return qe_invalid;
18180
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.spr_disappear,f))
18181 return qe_invalid;
18182
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.spr_walking,f))
18183 return qe_invalid;
18184
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_combo.spr_standing,f))
18185 return qe_invalid;
18186 96 }
18187 96 }
18188 68213 }
18189 210204 update_combo(temp_combo, s_version);
18190 210204 return 0;
18191 210204 }
18192 129 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18193 {
18194 129 word section_version=0;
18195 129 word section_cversion=0;
18196 129 word combos_used=0;
18197 int32_t dummy;
18198 byte padding;
18199 129 newcombo temp_combo;
18200
18201
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 reset_combo_animations();
18202
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 reset_combo_animations2();
18203
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 init_combo_classes();
18204
18205
2/2
✓ Branch 0 taken 8421120 times.
✓ Branch 1 taken 129 times.
8421249 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18206
1/2
✓ Branch 0 taken 8421120 times.
✗ Branch 1 not taken.
8421120 combobuf[q].clear();
18207
18208
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(version > 0x192) //Version info
18209 {
18210
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&section_version,f))
18211 {
18212 return qe_invalid;
18213 }
18214 125 FFCore.quest_format[vCombos] = section_version;
18215
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&section_cversion,f))
18216 {
18217 return qe_invalid;
18218 }
18219
18220 //section size
18221
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy,f))
18222 {
18223 return qe_invalid;
18224 }
18225 125 }
18226
18227
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(section_version > 32) //Cleanup time!
18228 {
18229
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
34 if(!p_igetw(&combos_used,f))
18230 {
18231 return qe_invalid;
18232 }
18233
2/2
✓ Branch 0 taken 210204 times.
✓ Branch 1 taken 34 times.
210238 for(int32_t i=0; i<combos_used; i++)
18234 {
18235
1/2
✓ Branch 0 taken 210204 times.
✗ Branch 1 not taken.
210204 auto ret = readcombo_loop(f,section_version,temp_combo);
18236
1/2
✓ Branch 0 taken 210204 times.
✗ Branch 1 not taken.
210204 if(ret) return ret;
18237
1/2
✓ Branch 0 taken 210204 times.
✗ Branch 1 not taken.
210204 if(i>=start_combo)
18238
1/2
✓ Branch 0 taken 210204 times.
✗ Branch 1 not taken.
210204 combobuf[i] = temp_combo;
18239 210204 }
18240 34 }
18241 else //Call the old function for all old versions
18242 {
18243
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18244
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 if(ret) return ret; //error, end read
18245 }
18246
18247
3/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 33 times.
129 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18248 {
18249 33 combobuf[0].walk = 0xF0;
18250 33 combobuf[0].type = 0;
18251 33 combobuf[0].flag = 0;
18252 33 }
18253
18254
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 setup_combo_animations();
18255
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 setup_combo_animations2();
18256 129 return 0;
18257 129 }
18258
18259 113 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18260 {
18261 //these are here to bypass compiler warnings about unused arguments
18262 113 Header=Header;
18263 113 version=version;
18264 113 build=build;
18265
18266 int32_t dummy;
18267 113 word sversion=0, c_sversion;
18268
18269 //section version info
18270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&sversion,f))
18271 {
18272 return qe_invalid;
18273 }
18274
18275 113 FFCore.quest_format[vComboAliases] = sversion;
18276
18277 //al_trace("Combo aliases version %d\n", sversion);
18278
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&c_sversion,f))
18279 {
18280 return qe_invalid;
18281 }
18282
18283 //section size
18284
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
18285 {
18286 return qe_invalid;
18287 }
18288
18289 113 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18290
18291
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18292 {
18293 77 max_num_combo_aliases = MAX250COMBOALIASES;
18294 77 }
18295
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18296 {
18297 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18298 }
18299
18300
2/2
✓ Branch 0 taken 452608 times.
✓ Branch 1 taken 113 times.
452721 for(int32_t j=0; j<max_num_combo_aliases; j++)
18301 {
18302 byte width,height,mask,tempcset;
18303 int32_t count;
18304 word tempword;
18305 byte tempbyte;
18306
18307
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_igetw(&tempword,f))
18308 {
18309 return qe_invalid;
18310 }
18311
18312 452608 combo_aliases[j].combo = tempword;
18313
18314
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&tempbyte,f))
18315 {
18316 return qe_invalid;
18317 }
18318
18319 452608 combo_aliases[j].cset = tempbyte;
18320
18321
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&width,f))
18322 {
18323 return qe_invalid;
18324 }
18325
18326
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&height,f))
18327 {
18328 return qe_invalid;
18329 }
18330
18331
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&mask,f))
18332 {
18333 return qe_invalid;
18334 }
18335
18336 452608 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18337
18338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452608 times.
452608 if(combo_aliases[j].combos != NULL)
18339 {
18340
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 delete[] combo_aliases[j].combos;
18341 452608 }
18342
18343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452608 times.
452608 if(combo_aliases[j].csets != NULL)
18344 {
18345
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 delete[] combo_aliases[j].csets;
18346 452608 }
18347
18348 452608 combo_aliases[j].width = width;
18349 452608 combo_aliases[j].height = height;
18350 452608 combo_aliases[j].layermask = mask;
18351 452608 combo_aliases[j].combos = new word[count];
18352 452608 combo_aliases[j].csets = new byte[count];
18353
18354
2/2
✓ Branch 0 taken 463957 times.
✓ Branch 1 taken 452608 times.
916565 for(int32_t k=0; k<count; k++)
18355 {
18356
1/2
✓ Branch 0 taken 463957 times.
✗ Branch 1 not taken.
463957 if(!p_igetw(&tempword,f))
18357 {
18358 return qe_invalid;
18359 }
18360
18361 463957 combo_aliases[j].combos[k] = tempword;
18362 463957 }
18363
18364
2/2
✓ Branch 0 taken 463957 times.
✓ Branch 1 taken 452608 times.
916565 for(int32_t k=0; k<count; k++)
18365 {
18366
1/2
✓ Branch 0 taken 463957 times.
✗ Branch 1 not taken.
463957 if(!p_getc(&tempcset,f))
18367 {
18368 return qe_invalid;
18369 }
18370
18371 463957 combo_aliases[j].csets[k] = tempcset;
18372 463957 }
18373 452608 }
18374
18375 113 word num_combo_pools = 0;
18376
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 34 times.
113 if(sversion >= 4)
18377 {
18378
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(!p_igetw(&num_combo_pools,f))
18379 {
18380 return qe_invalid;
18381 }
18382 34 }
18383
18384
2/2
✓ Branch 0 taken 925696 times.
✓ Branch 1 taken 113 times.
925809 for(combo_pool& pool : combo_pools)
18385 {
18386 925696 pool.clear();
18387 }
18388
18389 113 combo_pool temp_cpool;
18390
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 113 times.
209 for(word cp = 0; cp < num_combo_pools; ++cp)
18391 {
18392 96 int32_t num_combos_in_pool = 0;
18393
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetl(&num_combos_in_pool,f))
18394 {
18395 return qe_invalid;
18396 }
18397
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(num_combos_in_pool < 1) continue; //nothing to read
18398
18399
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 temp_cpool.clear();
18400
18401 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18402
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 416 times.
512 for(auto q = 0; q < num_combos_in_pool; ++q)
18403 {
18404
2/4
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 416 times.
✗ Branch 3 not taken.
416 if(!p_igetl(&cp_cid,f))
18405 {
18406 return qe_invalid;
18407 }
18408
2/4
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 416 times.
✗ Branch 3 not taken.
416 if(!p_getc(&cp_cs,f))
18409 {
18410 return qe_invalid;
18411 }
18412
2/4
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 416 times.
✗ Branch 3 not taken.
416 if(!p_igetw(&cp_quant,f))
18413 {
18414 return qe_invalid;
18415 }
18416
1/2
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
416 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18417 416 }
18418
18419
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 combo_pools[cp] = temp_cpool;
18420 96 }
18421
18422 113 return 0;
18423 113 }
18424
18425 129 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18426 {
18427 //these are here to bypass compiler warnings about unused arguments
18428
18429 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18430 //Capitalized cause it'll save you a headache. -Deedee
18431 129 start_cset=start_cset;
18432 129 max_csets=max_csets;
18433 129 word s_version=0;
18434
18435 miscQdata temp_misc;
18436 129 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18437
18438 byte temp_colordata[48];
18439 char temp_palname[PALNAMESIZE];
18440
18441 int32_t dummy;
18442 word palcycles;
18443
18444
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
18445 {
18446 //section version info
18447
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
18448 {
18449 return qe_invalid;
18450 }
18451
18452 125 FFCore.quest_format[vCSets] = s_version;
18453
18454 //al_trace("Color data version %d\n", s_version);
18455
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
18456 {
18457 return qe_invalid;
18458 }
18459
18460 //section size
18461
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
18462 {
18463 return qe_invalid;
18464 }
18465 125 }
18466
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if (s_version < 5)
18467 {
18468
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
93 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18469
18470 //finally... section data
18471 93 int32_t q = 0;
18472 93 int32_t p = -15;
18473
2/2
✓ Branch 0 taken 22320 times.
✓ Branch 1 taken 93 times.
22413 for(int32_t i=0; i<oldpdTOTAL; ++i)
18474 {
18475 22320 memset(temp_colordata, 0, 48);
18476
18477
1/2
✓ Branch 0 taken 22320 times.
✗ Branch 1 not taken.
22320 if(!pfread(temp_colordata,48,f))
18478 {
18479 return qe_invalid;
18480 }
18481
18482 22320 memcpy(&colordata[q*48], temp_colordata, 48);
18483
18484 22320 ++q;
18485
8/8
✓ Branch 0 taken 20832 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 1581 times.
✓ Branch 3 taken 19251 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 1395 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 178 times.
22320 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18486 {
18487
1/2
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
1573 if (s_version < 5) //Bumping up the size of level palettes
18488 {
18489 1573 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18490 1573 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18491 1573 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18492 1573 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18493 1573 q+=4;
18494 1573 }
18495 else
18496 {
18497 for(int m = 0; m < 4; ++m)
18498 {
18499 memset(temp_colordata, 0, 48);
18500 if(!pfread(temp_colordata,48,f))
18501 {
18502 return qe_invalid;
18503 }
18504 memcpy(&colordata[q*48], temp_colordata, 48);
18505 ++q;
18506 }
18507 }
18508 1573 }
18509 22320 ++p;
18510 22320 }
18511
18512
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if(RealOldVerion)
18513 {
18514 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18515 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18516 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18517 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18518 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18519 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18520 4 }
18521 else
18522 {
18523 89 memset(temp_colordata, 0, 48);
18524
18525
2/2
✓ Branch 0 taken 278837 times.
✓ Branch 1 taken 89 times.
278926 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18526 {
18527
1/2
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
278837 if(!pfread(temp_colordata,48,f))
18528 {
18529 return qe_invalid;
18530 }
18531
18532 278837 memcpy(&colordata[q*48], temp_colordata, 48);
18533
18534 278837 ++q;
18535
7/8
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21449 times.
✓ Branch 3 taken 257388 times.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 21271 times.
✓ Branch 6 taken 154 times.
✓ Branch 7 taken 24 times.
278837 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18536 {
18537
1/2
✓ Branch 0 taken 21425 times.
✗ Branch 1 not taken.
21425 if (s_version < 5) //Bumping up the size of level palettes
18538 {
18539 21425 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18540 21425 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18541 21425 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18542 21425 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18543 21425 q+=4;
18544 21425 }
18545 else
18546 {
18547 for(int m = 0; m < 4; ++m)
18548 {
18549 memset(temp_colordata, 0, 48);
18550 if(!pfread(temp_colordata,48,f))
18551 {
18552 return qe_invalid;
18553 }
18554 memcpy(&colordata[q*48], temp_colordata, 48);
18555 ++q;
18556 }
18557 }
18558 21425 }
18559 278837 ++p;
18560 278837 }
18561
18562
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 77 times.
89 if(s_version < 4)
18563 {
18564 12 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18565 12 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18566 12 }
18567 else
18568 {
18569
2/2
✓ Branch 0 taken 256256 times.
✓ Branch 1 taken 77 times.
256333 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18570 {
18571
1/2
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
256256 if(!pfread(temp_colordata,48,f))
18572 {
18573 return qe_invalid;
18574 }
18575
18576 256256 memcpy(&colordata[q*48], temp_colordata, 48);
18577 256256 ++q;
18578
5/6
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19712 times.
✓ Branch 3 taken 236544 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 19558 times.
256256 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18579 {
18580
1/2
✓ Branch 0 taken 19558 times.
✗ Branch 1 not taken.
19558 if (s_version < 5) //Bumping up the size of level palettes
18581 {
18582 19558 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18583 19558 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18584 19558 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18585 19558 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18586 19558 q+=4;
18587 19558 }
18588 else
18589 {
18590 for(int m = 0; m < 4; ++m)
18591 {
18592 memset(temp_colordata, 0, 48);
18593 if(!pfread(temp_colordata,48,f))
18594 {
18595 return qe_invalid;
18596 }
18597 memcpy(&colordata[q*48], temp_colordata, 48);
18598 ++q;
18599 }
18600 }
18601 19558 }
18602 256256 ++p;
18603 256256 }
18604
18605 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18606 }
18607 }
18608 93 }
18609 else
18610 {
18611
2/2
✓ Branch 0 taken 314964 times.
✓ Branch 1 taken 36 times.
315000 for(int32_t i=0; i<pdTOTAL255; ++i)
18612 {
18613 314964 memset(temp_colordata, 0, 48);
18614
18615
1/2
✓ Branch 0 taken 314964 times.
✗ Branch 1 not taken.
314964 if(!pfread(temp_colordata,48,f))
18616 {
18617 return qe_invalid;
18618 }
18619
18620 314964 memcpy(&colordata[i*48], temp_colordata, 48);
18621 314964 }
18622 }
18623
18624
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x192)||((version == 0x192)&&(build<76)))
18625 {
18626 4 init_palnames();
18627 4 }
18628 else
18629 {
18630 125 int32_t palnamestoread = 0;
18631
18632
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 3)
18633 12 palnamestoread = OLDMAXLEVELS;
18634 else
18635 113 palnamestoread = 512;
18636
18637
2/2
✓ Branch 0 taken 60928 times.
✓ Branch 1 taken 125 times.
61053 for(int32_t i=0; i<palnamestoread; ++i)
18638 {
18639 60928 memset(temp_palname, 0, PALNAMESIZE);
18640
18641
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(temp_palname,PALNAMESIZE,f))
18642 {
18643 return qe_invalid;
18644 }
18645
18646 60928 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18647 60928 }
18648
18649
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 125 times.
3197 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18650 {
18651 3072 memset(palnames[i], 0, PALNAMESIZE);
18652 3072 }
18653 }
18654
18655
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
18656 {
18657
2/2
✓ Branch 0 taken 32000 times.
✓ Branch 1 taken 125 times.
32125 for(int32_t i=0; i<256; i++)
18658 {
18659
2/2
✓ Branch 0 taken 96000 times.
✓ Branch 1 taken 32000 times.
128000 for(int32_t j=0; j<3; j++)
18660 {
18661 96000 temp_misc.cycles[i][j].first=0;
18662 96000 temp_misc.cycles[i][j].count=0;
18663 96000 temp_misc.cycles[i][j].speed=0;
18664 96000 }
18665 32000 }
18666
18667
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&palcycles,f))
18668 {
18669 return qe_invalid;
18670 }
18671
18672
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18673 {
18674 return qe_invalid;
18675 }
18676
18677
2/2
✓ Branch 0 taken 3560 times.
✓ Branch 1 taken 125 times.
3685 for(int32_t i=0; i<palcycles; i++)
18678 {
18679
2/2
✓ Branch 0 taken 10680 times.
✓ Branch 1 taken 3560 times.
14240 for(int32_t j=0; j<3; j++)
18680 {
18681
1/2
✓ Branch 0 taken 10680 times.
✗ Branch 1 not taken.
10680 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18682 {
18683 return qe_invalid;
18684 }
18685 10680 }
18686
18687
2/2
✓ Branch 0 taken 10680 times.
✓ Branch 1 taken 3560 times.
14240 for(int32_t j=0; j<3; j++)
18688 {
18689
1/2
✓ Branch 0 taken 10680 times.
✗ Branch 1 not taken.
10680 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18690 {
18691 return qe_invalid;
18692 }
18693 10680 }
18694
18695
2/2
✓ Branch 0 taken 10680 times.
✓ Branch 1 taken 3560 times.
14240 for(int32_t j=0; j<3; j++)
18696 {
18697
1/2
✓ Branch 0 taken 10680 times.
✗ Branch 1 not taken.
10680 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18698 {
18699 return qe_invalid;
18700 }
18701 10680 }
18702 3560 }
18703
18704 125 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18705 125 }
18706
18707 129 return 0;
18708 129 }
18709
18710 129 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18711 {
18712 129 int32_t tiles_used=0;
18713 129 word section_version = 0;
18714 129 word section_cversion = 0;
18715 129 int32_t section_size= 0;
18716 129 byte *temp_tile = new byte[tilesize(tf32Bit)];
18717
18718 //Tile Expansion
18719 //if ( version >= 0x254 && build >= 41 )
18720
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
129 if (version < 0x254 && build < 41)
18721 {
18722 //al_trace("Build was < 41 when reading tiles\n");
18723 93 max_tiles = ZC250MAXTILES;
18724 93 }
18725
18726 //al_trace("Max Tiles: %d\n", max_tiles);
18727
18728
2/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18729 {
18730 if(!init_tiles(true, Header))
18731 {
18732 al_trace("Unable to initialize tiles\n");
18733 }
18734
18735 delete[] temp_tile;
18736 temp_tile=NULL;
18737 return 0;
18738 }
18739 else
18740 {
18741
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
18742 {
18743 //section version info
18744
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_version,f))
18745 {
18746 delete[] temp_tile;
18747 return qe_invalid;
18748 }
18749
18750 125 FFCore.quest_format[vTiles] = section_version;
18751
18752
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_cversion,f))
18753 {
18754 delete[] temp_tile;
18755 return qe_invalid;
18756 }
18757
18758 //section size
18759
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&section_size,f))
18760 {
18761 delete[] temp_tile;
18762 return qe_invalid;
18763 }
18764 125 }
18765
18766 //if ( build < 41 )
18767 //{
18768 // tiles_used = ZC250MAXTILES;
18769 //}
18770
18771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(version < 0x174)
18772 {
18773 tiles_used=TILES_PER_PAGE*4;
18774 } //no expanded tile space
18775
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 else if(version < 0x191)
18776 {
18777 4 tiles_used=OLDMAXTILES;
18778 4 }
18779 else
18780 {
18781 //finally... section data
18782
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
125 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18783 {
18784
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tiles_used,f))
18785 {
18786 delete[] temp_tile;
18787 return qe_invalid;
18788 }
18789 36 }
18790 else
18791 {
18792
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_igetw(&tiles_used,f))
18793 {
18794 delete[] temp_tile;
18795 return qe_invalid;
18796 }
18797 }
18798 }
18799
18800
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 tiles_used=zc_min(tiles_used, max_tiles);
18801
18802 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18803 //if ( version < 0x254 && build < 41 )
18804
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if ( version < 0x254 || (version == 0x254 && build < 41) )
18805 //if ( build < 41 )
18806 {
18807
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18808 93 }
18809 else //2.55
18810 {
18811
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18812 }
18813
18814 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18815
18816 //al_trace("tiles_used = %d\n", tiles_used);
18817
18818
2/2
✓ Branch 0 taken 3485958 times.
✓ Branch 1 taken 129 times.
3486087 for(int32_t i=0; i<tiles_used; ++i)
18819 {
18820 3485958 byte format=tf4Bit;
18821 3485958 memset(temp_tile, 0, tilesize(tf32Bit));
18822
18823
3/6
✓ Branch 0 taken 630780 times.
✓ Branch 1 taken 2855178 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 630780 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3485958 if((version>0x211)||((version==0x211)&&(build>4)))
18824 {
18825
1/2
✓ Branch 0 taken 2855178 times.
✗ Branch 1 not taken.
2855178 if(!p_getc(&format,f))
18826 {
18827 delete[] temp_tile;
18828 return qe_invalid;
18829 }
18830 2855178 }
18831
4/4
✓ Branch 0 taken 1305624 times.
✓ Branch 1 taken 2180334 times.
✓ Branch 2 taken 599285 times.
✓ Branch 3 taken 706339 times.
3485958 if(section_version > 2 && !format)
18832 {
18833 706339 reset_tile(buf,start_tile+i,tf4Bit);
18834 706339 continue;
18835 }
18836
18837
1/2
✓ Branch 0 taken 2779619 times.
✗ Branch 1 not taken.
2779619 if(!pfread(temp_tile,tilesize(format),f))
18838 {
18839 delete[] temp_tile;
18840 return qe_invalid;
18841 }
18842
18843 2779619 buf[start_tile+i].format=format;
18844
18845
1/2
✓ Branch 0 taken 2779619 times.
✗ Branch 1 not taken.
2779619 if(buf[start_tile+i].data)
18846 {
18847 2779619 free(buf[start_tile+i].data);
18848 2779619 buf[start_tile+i].data=NULL;
18849 2779619 }
18850
18851 2779619 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
18852 2779619 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
18853 2779619 }
18854 }
18855
18856
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
18857 {
18858 //al_trace("Writing blank tile data to new tiles for build < 41\n");
18859
2/2
✓ Branch 0 taken 13855140 times.
✓ Branch 1 taken 93 times.
13855233 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
18860 {
18861
18862 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
18863 13855140 reset_tile(buf,q,tf4Bit);
18864
18865
18866 /*
18867
18868 byte tempbyte;
18869 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18870 {
18871 tempbyte=buf[ZC250MAXTILES-1].data[i];
18872 buf[q].data[i] = tempbyte;
18873 }
18874 //int32_t temp = tempbyte=buf[130].data[i];
18875 //buf[q].data = buf[ZC250MAXTILES-1].data;
18876 */
18877 //reset_tile(buf,q,tf4Bit);
18878 13855140 }
18879
18880 93 }
18881
18882
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
18883 {
18884
2/2
✓ Branch 0 taken 4121646 times.
✓ Branch 1 taken 93 times.
4121739 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18885 {
18886 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
18887 4121646 reset_tile(buf,i,tf4Bit);
18888 4121646 }
18889 93 }
18890 else
18891 {
18892
2/2
✓ Branch 0 taken 6207756 times.
✓ Branch 1 taken 36 times.
6207792 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18893 {
18894 //al_trace("Resetting tiles for build 41+\n");
18895 6207756 reset_tile(buf,i,tf4Bit);
18896 6207756 }
18897 }
18898
18899
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
18900 {
18901
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_qr(qr_BSZELDA)) //
18902 {
18903 byte tempbyte;
18904 int32_t floattile=wpnsbuf[iwSwim].tile;
18905
18906 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
18907 {
18908 tempbyte=buf[23].data[i];
18909 buf[23].data[i]=buf[24].data[i];
18910 buf[24].data[i]=buf[25].data[i];
18911 buf[25].data[i]=buf[26].data[i];
18912 buf[26].data[i]=tempbyte;
18913 }
18914 //swim tiles are out of order, too, but nobody cared? -Z
18915 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18916 {
18917 tempbyte=buf[floattile+11].data[i];
18918 buf[floattile+11].data[i]=buf[floattile+12].data[i];
18919 buf[floattile+12].data[i]=tempbyte;
18920 }
18921 }
18922 4 }
18923
18924
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
18925 {
18926
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(!get_qr(qr_NEWENEMYTILES))
18927 {
18928 byte tempbyte;
18929
18930
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18931 {
18932 512 tempbyte=buf[130].data[i];
18933 512 buf[130].data[i]=buf[132].data[i];
18934 512 buf[132].data[i]=tempbyte;
18935
18936 512 tempbyte=buf[131].data[i];
18937 512 buf[131].data[i]=buf[133].data[i];
18938 512 buf[133].data[i]=tempbyte;
18939 512 }
18940 4 }
18941 16 }
18942
18943 129 al_trace("Registering blank tiles\n");
18944 129 register_blank_tiles();
18945
18946 //memset(temp_tile, 0, tilesize(tf32Bit));
18947
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 delete[] temp_tile;
18948 129 temp_tile=NULL;
18949 129 return 0;
18950 129 }
18951
18952 129 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
18953 {
18954 129 byte *mf=midi_flags;
18955 int32_t dummy;
18956 word dummy2;
18957 // zcmidi_ temp_midi;
18958 int32_t tunes_to_read;
18959 129 int32_t tune_count=0;
18960 129 word section_version=0;
18961 129 zctune temp;
18962
18963
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version < 0x193)
18964 {
18965 // mf=Header->data_flags+ZQ_MIDIS2;
18966
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
18967 {
18968 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
18969 4 }
18970 else
18971 {
18972 tunes_to_read=MAXCUSTOMTUNES;
18973 }
18974 4 }
18975 else
18976 {
18977 //section version info
18978
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_version,f))
18979 {
18980 return qe_invalid;
18981 }
18982
18983 125 FFCore.quest_format[vMIDIs] = section_version;
18984
18985 //al_trace("Tunes version %d\n", section_version);
18986
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy2,f))
18987 {
18988 return qe_invalid;
18989 }
18990
18991 //section size
18992
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
18993 {
18994 return qe_invalid;
18995 }
18996
18997 //finally... section data
18998
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(midi_flags,sizeof(midi_flags),f))
18999 {
19000 return qe_invalid;
19001 }
19002
19003 125 tunes_to_read=MAXCUSTOMTUNES;
19004 }
19005
19006
2/2
✓ Branch 0 taken 32508 times.
✓ Branch 1 taken 129 times.
32637 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19007 {
19008
2/2
✓ Branch 0 taken 30214 times.
✓ Branch 1 taken 2294 times.
32508 if(get_bit(mf, i))
19009 {
19010 2294 ++tune_count;
19011 2294 }
19012 32508 }
19013
19014 129 reset_tunes(tunes); //reset_midis(midis);
19015
19016
2/2
✓ Branch 0 taken 31628 times.
✓ Branch 1 taken 129 times.
31757 for(int32_t i=0; i<tunes_to_read; i++)
19017 {
19018 31628 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19019
19020 31628 tunes[i].reset(); // reset_midi(midis+i);
19021
19022
2/2
✓ Branch 0 taken 29334 times.
✓ Branch 1 taken 2294 times.
31628 if(get_bit(mf,i))
19023 {
19024
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1577 times.
2294 if(section_version < 4)
19025 {
19026
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(!pfread(&temp.title,sizeof(char)*20,f))
19027 {
19028 return qe_invalid;
19029 }
19030 717 }
19031 else
19032 {
19033
1/2
✓ Branch 0 taken 1577 times.
✗ Branch 1 not taken.
1577 if(!pfread(&temp.title,sizeof(temp.title),f))
19034 {
19035 return qe_invalid;
19036 }
19037 }
19038
19039
1/2
✓ Branch 0 taken 2294 times.
✗ Branch 1 not taken.
2294 if(!p_igetl(&temp.start,f))
19040 {
19041 return qe_invalid;
19042 }
19043
19044
1/2
✓ Branch 0 taken 2294 times.
✗ Branch 1 not taken.
2294 if(!p_igetl(&temp.loop_start,f))
19045 {
19046 return qe_invalid;
19047 }
19048
19049
1/2
✓ Branch 0 taken 2294 times.
✗ Branch 1 not taken.
2294 if(!p_igetl(&temp.loop_end,f))
19050 {
19051 return qe_invalid;
19052 }
19053
19054
1/2
✓ Branch 0 taken 2294 times.
✗ Branch 1 not taken.
2294 if(!p_igetw(&temp.loop,f))
19055 {
19056 return qe_invalid;
19057 }
19058
19059
1/2
✓ Branch 0 taken 2294 times.
✗ Branch 1 not taken.
2294 if(!p_igetw(&temp.volume,f))
19060 {
19061 return qe_invalid;
19062 }
19063
19064
2/2
✓ Branch 0 taken 2216 times.
✓ Branch 1 taken 78 times.
2294 if(Header->zelda_version < 0x193)
19065 {
19066
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f))
19067 {
19068 return qe_invalid;
19069 }
19070 78 }
19071
19072
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1577 times.
2294 if(section_version >= 3)
19073 {
19074
1/2
✓ Branch 0 taken 1577 times.
✗ Branch 1 not taken.
1577 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19075 {
19076 return qe_invalid;
19077 }
19078 1577 }
19079
19080 2294 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19081
19082
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1577 times.
2294 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19083 {
19084 // old format - a midi is a midi
19085
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if((tunes[i].data=read_midi(f))==NULL)
19086 {
19087 return qe_invalid;
19088 }
19089
19090 //yes you can do this. Isn't the ? operator awesome? :)
19091 717 tunes[i].format = MFORMAT_MIDI;
19092 717 }
19093 else
19094 {
19095 // 'midi' could be midi or nes, gb, ... music
19096
1/2
✓ Branch 0 taken 1577 times.
✗ Branch 1 not taken.
1577 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19097 {
19098 return qe_invalid;
19099 }
19100
19101 1577 zctune *ptr = &tunes[i];
19102
19103
1/2
✓ Branch 0 taken 1577 times.
✗ Branch 1 not taken.
1577 switch(temp.format)
19104 {
19105 case MFORMAT_MIDI:
19106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1577 times.
1577 if((ptr->data=read_midi(f))==NULL)
19107 {
19108 return qe_invalid;
19109 }
19110
19111 1577 break;
19112
19113 default:
19114 return qe_invalid;
19115 break;
19116 }
19117 }
19118 2294 }
19119 31628 }
19120
19121 129 return 0;
19122 129 }
19123
19124 129 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19125 {
19126 int32_t dummy;
19127 ZCHEATS tempzcheats;
19128 129 char temp_use_cheats=1;
19129 129 memset(&tempzcheats, 0, sizeof(tempzcheats));
19130 129 word s_version = 0;
19131
19132
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
19133 {
19134 //section version info
19135
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
19136 {
19137 return qe_invalid;
19138 }
19139
19140 125 FFCore.quest_format[vCheats] = s_version;
19141 //al_trace("Cheats version %d\n", dummy);
19142
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
19143 {
19144 return qe_invalid;
19145 }
19146
19147 //section size
19148
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
19149 {
19150 return qe_invalid;
19151 }
19152
19153 //finally... section data
19154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(!p_getc(&temp_use_cheats,f))
19155 {
19156 return qe_invalid;
19157 }
19158 125 }
19159
19160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(Header->data_flags[ZQ_CHEATS2])
19161 {
19162
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_igetl(&tempzcheats.flags,f))
19163 {
19164 return qe_invalid;
19165 }
19166
19167
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19168 {
19169 return qe_invalid;
19170 }
19171 129 }
19172
19173 129 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19174 129 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19175
19176 129 return 0;
19177 129 }
19178
19179 285 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
19180 {
19181 int32_t dummy;
19182 285 word s_version=0, s_cversion=0;
19183 byte padding;
19184
19185 285 zinitdata temp_zinit;
19186
19187 // Legacy item properties (now integrated into itemdata)
19188 byte sword_hearts[4];
19189 byte beam_hearts[4];
19190 285 byte beam_percent=0;
19191 word beam_power[4];
19192 285 byte hookshot_length=99;
19193 285 byte hookshot_links=100;
19194 285 byte longshot_length=99;
19195 285 byte longshot_links=100;
19196 285 byte moving_fairy_hearts=3;
19197 285 byte moving_fairy_heart_percent=0;
19198 285 byte stationary_fairy_hearts=3;
19199 285 byte stationary_fairy_heart_percent=0;
19200 285 byte moving_fairy_magic=0;
19201 285 byte moving_fairy_magic_percent=0;
19202 285 byte stationary_fairy_magic=0;
19203 285 byte stationary_fairy_magic_percent=0;
19204 285 byte blue_potion_hearts=100;
19205 285 byte blue_potion_heart_percent=1;
19206 285 byte red_potion_hearts=100;
19207 285 byte red_potion_heart_percent=1;
19208 285 byte blue_potion_magic=100;
19209 285 byte blue_potion_magic_percent=1;
19210 285 byte red_potion_magic=100;
19211 285 byte red_potion_magic_percent=1;
19212
19213
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 156 times.
285 temp_zinit.subscreen_style=get_qr(qr_COOLSCROLL)?1:0;
19214
19215
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version > 0x192)
19216 {
19217 //section version info
19218
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_version,f))
19219 {
19220 return qe_invalid;
19221 }
19222
19223 125 FFCore.quest_format[vInitData] = s_version;
19224
19225 //al_trace("Init data version %d\n", s_version);
19226
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_cversion,f))
19227 {
19228 return qe_invalid;
19229 }
19230
19231 //section size
19232
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy,f))
19233 {
19234 return qe_invalid;
19235 }
19236 125 }
19237
19238 /* HIGHLY UNORTHODOX UPDATING THING, by L
19239 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19240 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19241 * changing from 13 to 14.
19242 */
19243
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 14)
19244 16 fixpolsvoice=true;
19245
19246 /* End highly unorthodox updating thing */
19247
19248
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 38 times.
129 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19249 38 temp_zinit.jump_hero_layer_threshold=0;
19250
19251
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version >= 10)
19252 {
19253 char temp;
19254
19255 //new-style items
19256
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t j=0; j<256; j++)
19257 {
19258
2/4
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28928 times.
28928 if(!p_getc(&temp,f))
19259 return qe_invalid;
19260
19261 28928 temp_zinit.items[j] = (temp != 0);
19262 28928 }
19263 113 }
19264
19265
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 31 times.
✓ Branch 5 taken 31 times.
129 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19266 {
19267 char temp;
19268
19269 //finally... section data
19270
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 31 times.
156 if((Header->zelda_version > 0x192)||
19271 //new only
19272 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19273 {
19274 //OLD-style items... sigh
19275
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 10)
19276 {
19277
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19278 {
19279 return qe_invalid;
19280 }
19281
19282 12 temp_zinit.items[iRaft]=(temp != 0);
19283
19284
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19285 {
19286 return qe_invalid;
19287 }
19288
19289 12 temp_zinit.items[iLadder]=(temp != 0);
19290
19291
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19292 {
19293 return qe_invalid;
19294 }
19295
19296 12 temp_zinit.items[iBook]=(temp != 0);
19297
19298
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19299 {
19300 return qe_invalid;
19301 }
19302
19303 12 temp_zinit.items[iMKey]=(temp!=0);
19304
19305
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19306 {
19307 return qe_invalid;
19308 }
19309
19310 12 temp_zinit.items[iFlippers]=(temp != 0);
19311
19312
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19313 {
19314 return qe_invalid;
19315 }
19316
19317 12 temp_zinit.items[iBoots]=(temp!=0);
19318 12 }
19319 125 }
19320
19321
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 142 times.
156 if(s_version < 10)
19322 {
19323 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19324
19325
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempring,f))
19326 {
19327 return qe_invalid;
19328 }
19329
19330
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempsword,f))
19331 {
19332 return qe_invalid;
19333 }
19334
19335
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempshield,f))
19336 {
19337 return qe_invalid;
19338 }
19339
19340
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwallet,f))
19341 {
19342 return qe_invalid;
19343 }
19344
19345
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbracelet,f))
19346 {
19347 return qe_invalid;
19348 }
19349
19350
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempamulet,f))
19351 {
19352 return qe_invalid;
19353 }
19354
19355
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbow,f))
19356 {
19357 return qe_invalid;
19358 }
19359
19360 //old only
19361
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19362 {
19363 tempring=(tempring)?(1<<(tempring-1)):0;
19364 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19365 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19366 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19367 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19368 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19369 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19370 }
19371
19372 //rings start at level 2... wtf
19373 //account for this -DD
19374 12 tempring <<= 1;
19375
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19376
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19377
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19378
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19379 //bracelet ALSO starts at level 2 :-( -DD
19380 12 tempbracelet<<=1;
19381
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19382
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19383
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19384
19385 //new only
19386
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build>173))
19387 {
19388 for(int32_t q=0; q<32; q++)
19389 {
19390 if(!p_getc(&padding,f))
19391 {
19392 return qe_invalid;
19393 }
19394 }
19395 }
19396
19397 char tempcandle, tempboomerang, temparrow, tempwhistle;
19398
19399
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempcandle,f))
19400 {
19401 return qe_invalid;
19402 }
19403
19404
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempboomerang,f))
19405 {
19406 return qe_invalid;
19407 }
19408
19409
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temparrow,f))
19410 {
19411 return qe_invalid;
19412 }
19413
19414
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19415 {
19416 return qe_invalid;
19417 }
19418
19419
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19420
19421
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwhistle,f))
19422 {
19423 return qe_invalid;
19424 }
19425
19426 //old only
19427
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19428 {
19429 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19430 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19431 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19432 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19433 }
19434
19435
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19436
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19437
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19438
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19439 //What about the potion...?
19440
19441 12 }
19442
19443
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 65 times.
154 if(s_version < 29)
19444 {
19445 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19446 //to jab out my eye...
19447
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19448 return qe_invalid;
19449 89 temp_zinit.bombs = padding;
19450
19451
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19452 return qe_invalid;
19453 89 temp_zinit.super_bombs = padding;
19454 89 }
19455
19456 //Back to more OLD item code
19457
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
154 if(s_version < 10)
19458 {
19459
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version > 0x192)||
19460 //new only
19461 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19462 {
19463
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19464 {
19465 return qe_invalid;
19466 }
19467
19468
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19469
19470
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19471 {
19472 return qe_invalid;
19473 }
19474
19475
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19476
19477
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19478 {
19479 return qe_invalid;
19480 }
19481
19482
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19483
19484
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19485 {
19486 return qe_invalid;
19487 }
19488
19489
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19490
19491
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19492 {
19493 return qe_invalid;
19494 }
19495
19496
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19497
19498
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19499 {
19500 return qe_invalid;
19501 }
19502
19503
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19504
19505
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19506 {
19507 return qe_invalid;
19508 }
19509
19510
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19511
19512
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19513 {
19514 return qe_invalid;
19515 }
19516
19517
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19518
19519
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19520 {
19521 return qe_invalid;
19522 }
19523
19524
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19525
19526
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19527 {
19528 return qe_invalid;
19529 }
19530
19531
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(Header->zelda_version == 0x192)
19532 {
19533 for(int32_t q=0; q<32; q++)
19534 {
19535 if(!p_getc(&padding,f))
19536 {
19537 return qe_invalid;
19538 }
19539 }
19540 }
19541 12 }
19542 12 }
19543
19544 //old only
19545
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if((Header->zelda_version == 0x192)&&(Header->build<174))
19546 {
19547 byte equipment, items; //bit flags
19548
19549 if(!p_getc(&equipment,f))
19550 {
19551 return qe_invalid;
19552 }
19553
19554 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19555 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19556 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19557 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19558 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19559 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19560
19561
19562 if(!p_getc(&items,f))
19563 {
19564 return qe_invalid;
19565 }
19566
19567 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19568 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19569 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19570 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19571 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19572 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19573 }
19574
19575 if(!p_getc(&temp_zinit.hc,f))
19576 {
19577 return qe_invalid;
19578 }
19579
19580
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 14)
19581 {
19582 byte temphp;
19583
19584
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19585 {
19586 return qe_invalid;
19587 }
19588
19589 12 temp_zinit.start_heart=temphp;
19590
19591
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19592 {
19593 return qe_invalid;
19594 }
19595
19596 12 temp_zinit.cont_heart=temphp;
19597 12 }
19598 else
19599 {
19600
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.start_heart,f))
19601 {
19602 return qe_invalid;
19603 }
19604
19605
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.cont_heart,f))
19606 {
19607 return qe_invalid;
19608 }
19609 }
19610
19611
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.hcp,f))
19612 {
19613 return qe_invalid;
19614 }
19615
19616
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version >= 14)
19617 {
19618
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19619 {
19620 return qe_invalid;
19621 }
19622
19623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version<16) // July 2007
19624 {
19625 if(get_qr(qr_BRANGPICKUP+1))
19626 temp_zinit.hcp_per_hc = 0xFF;
19627
19628 //Dispose of legacy rule
19629 set_qr(qr_BRANGPICKUP+1, 0);
19630 }
19631 113 }
19632
19633
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version < 29)
19634 {
19635
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19636 return qe_invalid;
19637 89 temp_zinit.max_bombs = padding;
19638 89 }
19639
19640
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.keys,f))
19641 {
19642 return qe_invalid;
19643 }
19644
19645
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&temp_zinit.rupies,f))
19646 {
19647 return qe_invalid;
19648 }
19649
19650
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.triforce,f))
19651 {
19652 return qe_invalid;
19653 }
19654
19655
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19656 {
19657
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
19658 {
19659
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.map[i],f))
19660 {
19661 return qe_invalid;
19662 }
19663 7232 }
19664
19665
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
19666 {
19667
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.compass[i],f))
19668 {
19669 return qe_invalid;
19670 }
19671 7232 }
19672 113 }
19673 else
19674 {
19675
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19676 {
19677
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.map[i],f))
19678 {
19679 return qe_invalid;
19680 }
19681 384 }
19682
19683
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19684 {
19685
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.compass[i],f))
19686 {
19687 return qe_invalid;
19688 }
19689 384 }
19690 }
19691
19692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version > 0x192)||
19693 //new only
19694 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19695 {
19696
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19697 {
19698
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
19699 {
19700
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.boss_key[i],f))
19701 {
19702 return qe_invalid;
19703 }
19704 7232 }
19705 113 }
19706 else
19707 {
19708
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19709 {
19710
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 384 times.
✗ Branch 3 not taken.
384 if(!p_getc(&temp_zinit.boss_key[i],f))
19711 {
19712 return qe_invalid;
19713 }
19714 384 }
19715 }
19716 125 }
19717
19718
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 2000 times.
2125 for(int32_t i=0; i<16; i++)
19719 {
19720
2/4
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2000 times.
2000 if(!p_getc(&temp_zinit.misc[i],f))
19721 {
19722 return qe_invalid;
19723 }
19724 2000 }
19725
19726
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 12 times.
173 if(s_version < 15) for(int32_t i=0; i<4; i++)
19727 {
19728
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&sword_hearts[i],f))
19729 {
19730 return qe_invalid;
19731 }
19732 60 }
19733
19734
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.last_map,f))
19735 {
19736 return qe_invalid;
19737 }
19738
19739
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.last_screen,f))
19740 {
19741 return qe_invalid;
19742 }
19743
19744
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 14)
19745 {
19746 byte tempmp;
19747
19748
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
19749 {
19750 return qe_invalid;
19751 }
19752
19753 12 temp_zinit.max_magic=tempmp;
19754
19755
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
19756 {
19757 return qe_invalid;
19758 }
19759
19760 12 temp_zinit.magic=tempmp;
19761 12 }
19762 else
19763 {
19764
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_magic,f))
19765 {
19766 return qe_invalid;
19767 }
19768
19769
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.magic,f))
19770 {
19771 return qe_invalid;
19772 }
19773 }
19774
19775
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version < 15)
19776 {
19777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version < 12)
19778 {
19779 12 temp_zinit.max_magic*=32;
19780 12 temp_zinit.magic*=32;
19781 12 }
19782
19783
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
19784 {
19785
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&beam_hearts[i],f))
19786 {
19787 return qe_invalid;
19788 }
19789 48 }
19790
19791
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&beam_percent,f))
19792 {
19793 return qe_invalid;
19794 }
19795 12 }
19796 else
19797 {
19798
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.bomb_ratio,f))
19799 {
19800 return qe_invalid;
19801 }
19802 }
19803
19804
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version < 15)
19805 {
19806 byte tempbp;
19807
19808
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
19809 {
19810
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19811 {
19812 return qe_invalid;
19813 }
19814
19815 48 beam_power[i]=tempbp;
19816 48 }
19817
19818
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&hookshot_links,f))
19819 {
19820 return qe_invalid;
19821 }
19822
19823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version>6)
19824 {
19825 if(!p_getc(&hookshot_length,f))
19826 {
19827 return qe_invalid;
19828 }
19829
19830 if(!p_getc(&longshot_links,f))
19831 {
19832 return qe_invalid;
19833 }
19834
19835 if(!p_getc(&longshot_length,f))
19836 {
19837 return qe_invalid;
19838 }
19839 }
19840 12 }
19841
19842
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.msg_more_x,f))
19843 {
19844 return qe_invalid;
19845 }
19846
19847
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.msg_more_y,f))
19848 {
19849 return qe_invalid;
19850 }
19851
19852
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.subscreen,f))
19853 {
19854 return qe_invalid;
19855 }
19856
19857 //old only
19858
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version == 0x192)&&(Header->build<174))
19859 {
19860 for(int32_t i=0; i<32; i++)
19861 {
19862 if(!p_getc(&temp_zinit.boss_key[i],f))
19863 {
19864 return qe_invalid;
19865 }
19866 }
19867 }
19868
19869
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
19870 {
19871
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version <= 10)
19872 {
19873 byte tempbyte;
19874
19875
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbyte,f))
19876 {
19877 return qe_invalid;
19878 }
19879
19880 12 temp_zinit.start_dmap = (word)tempbyte;
19881 12 }
19882 else
19883 {
19884
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.start_dmap,f))
19885 {
19886 return qe_invalid;
19887 }
19888 }
19889
19890
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
19891 {
19892 return qe_invalid;
19893 }
19894 125 }
19895
19896
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
125 if(s_version>1 && s_version < 29)
19897 {
19898
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
19899 return qe_invalid;
19900 77 temp_zinit.arrows = padding;
19901
19902
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
19903 return qe_invalid;
19904 77 temp_zinit.max_arrows = padding;
19905 77 }
19906
19907
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version>2)
19908 {
19909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version <= 10)
19910 {
19911 for(int32_t i=0; i<OLDMAXLEVELS; i++)
19912 {
19913 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19914 {
19915 return qe_invalid;
19916 }
19917 }
19918 }
19919 else
19920 {
19921
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXLEVELS; i++)
19922 {
19923
2/4
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57856 times.
✗ Branch 3 not taken.
57856 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19924 {
19925 return qe_invalid;
19926 }
19927 57856 }
19928 }
19929 113 }
19930
19931
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>3)
19932 {
19933
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_x,f))
19934 {
19935 return qe_invalid;
19936 }
19937
19938
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_y,f))
19939 {
19940 return qe_invalid;
19941 }
19942
19943
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
19944 {
19945 return qe_invalid;
19946 }
19947
19948
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
19949 {
19950 return qe_invalid;
19951 }
19952
19953
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_color,f))
19954 {
19955 return qe_invalid;
19956 }
19957
19958
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
19959 {
19960 return qe_invalid;
19961 }
19962
19963
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
19964 {
19965 return qe_invalid;
19966 }
19967
19968
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_flags,f))
19969 {
19970 return qe_invalid;
19971 }
19972
19973
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
19974
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
19975 113 }
19976
19977
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>4 && s_version<15)
19978 {
19979 if(!p_getc(&moving_fairy_hearts,f))
19980 {
19981 return qe_invalid;
19982 }
19983
19984 if(!p_getc(&moving_fairy_heart_percent,f))
19985 {
19986 return qe_invalid;
19987 }
19988 }
19989
19990
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>5 && s_version < 10)
19991 {
19992 if(!p_getc(&temp,f))
19993 {
19994 return qe_invalid;
19995 }
19996
19997 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
19998 }
19999
20000
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>6 && s_version<15)
20001 {
20002 if(!p_getc(&stationary_fairy_hearts,f))
20003 {
20004 return qe_invalid;
20005 }
20006
20007 if(!p_getc(&stationary_fairy_heart_percent,f))
20008 {
20009 return qe_invalid;
20010 }
20011
20012 if(!p_getc(&moving_fairy_magic,f))
20013 {
20014 return qe_invalid;
20015 }
20016
20017 if(!p_getc(&moving_fairy_magic_percent,f))
20018 {
20019 return qe_invalid;
20020 }
20021
20022 if(!p_getc(&stationary_fairy_magic,f))
20023 {
20024 return qe_invalid;
20025 }
20026
20027 if(!p_getc(&stationary_fairy_magic_percent,f))
20028 {
20029 return qe_invalid;
20030 }
20031
20032 if(!p_getc(&blue_potion_hearts,f))
20033 {
20034 return qe_invalid;
20035 }
20036
20037 if(!p_getc(&blue_potion_heart_percent,f))
20038 {
20039 return qe_invalid;
20040 }
20041
20042 if(!p_getc(&red_potion_hearts,f))
20043 {
20044 return qe_invalid;
20045 }
20046
20047 if(!p_getc(&red_potion_heart_percent,f))
20048 {
20049 return qe_invalid;
20050 }
20051
20052 if(!p_getc(&blue_potion_magic,f))
20053 {
20054 return qe_invalid;
20055 }
20056
20057 if(!p_getc(&blue_potion_magic_percent,f))
20058 {
20059 return qe_invalid;
20060 }
20061
20062 if(!p_getc(&red_potion_magic,f))
20063 {
20064 return qe_invalid;
20065 }
20066
20067 if(!p_getc(&red_potion_magic_percent,f))
20068 {
20069 return qe_invalid;
20070 }
20071 }
20072
20073
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>6)
20074 {
20075
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.subscreen_style,f))
20076 {
20077 return qe_invalid;
20078 }
20079 113 }
20080
20081
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>7)
20082 {
20083
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.usecustomsfx,f))
20084 {
20085 return qe_invalid;
20086 }
20087 113 }
20088
20089
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>8)
20090 {
20091
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_rupees,f))
20092 {
20093 return qe_invalid;
20094 }
20095
20096
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_keys,f))
20097 {
20098 return qe_invalid;
20099 }
20100 113 }
20101
20102
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>16)
20103 {
20104
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.gravity,f))
20105 {
20106 return qe_invalid;
20107 }
20108
20109
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.terminalv,f))
20110 {
20111 return qe_invalid;
20112 }
20113
20114
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.msg_speed,f))
20115 {
20116 return qe_invalid;
20117 }
20118
20119
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.transition_type,f))
20120 {
20121 return qe_invalid;
20122 }
20123
20124
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20125 {
20126 return qe_invalid;
20127 }
20128 113 }
20129
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 else if (replay_version_check(0, 13))
20130 12 temp_zinit.msg_speed = 0;
20131
20132
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>17)
20133 {
20134
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20135 {
20136 return qe_invalid;
20137 }
20138 113 }
20139
20140 //expaned init data for larger values in 2.55
20141
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20142 {
20143
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.bombs,f))
20144 {
20145 return qe_invalid;
20146 }
20147
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.super_bombs,f))
20148 {
20149 return qe_invalid;
20150 }
20151
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_bombs,f))
20152 {
20153 return qe_invalid;
20154 }
20155
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_sbombs,f))
20156 {
20157 return qe_invalid;
20158 }
20159
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.arrows,f))
20160 {
20161 return qe_invalid;
20162 }
20163
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_arrows,f))
20164 {
20165 return qe_invalid;
20166 }
20167
20168 36 }
20169
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 20 )
20170 {
20171
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroStep,f))
20172 {
20173 return qe_invalid;
20174 }
20175 36 }
20176 else
20177 {
20178 89 temp_zinit.heroStep = 150; //1.5 pixels per frame
20179 }
20180
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 21 )
20181 {
20182
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20183 {
20184 return qe_invalid;
20185 }
20186 36 }
20187 else
20188 {
20189 89 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20190 }
20191 //old only
20192
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version == 0x192)&&(Header->build<174))
20193 {
20194 byte items2;
20195
20196 if(!p_getc(&items2,f))
20197 {
20198 return qe_invalid;
20199 }
20200
20201 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20202 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20203 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20204 }
20205
20206
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
20207 {
20208 for(int32_t q=0; q<96; q++)
20209 {
20210 if(!p_getc(&padding,f))
20211 {
20212 return qe_invalid;
20213 }
20214 }
20215
20216 //new only
20217 if((Header->zelda_version == 0x192)&&(Header->build>173))
20218 {
20219 if(!p_getc(&padding,f))
20220 {
20221 return qe_invalid;
20222 }
20223
20224 if(!p_getc(&padding,f))
20225 {
20226 return qe_invalid;
20227 }
20228 }
20229 }
20230 125 }
20231
20232
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20233 {
20234 //temp_zinit.shield=i_smallshield;
20235
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 31 times.
47 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20236
20237
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(sshieldid != -1)
20238 16 temp_zinit.items[sshieldid] = true;
20239 16 }
20240
20241
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20242 {
20243 4 temp_zinit.hc=3;
20244 4 temp_zinit.start_heart=3;
20245 4 temp_zinit.cont_heart=3;
20246 4 temp_zinit.max_bombs=8;
20247 4 }
20248
20249
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20250 {
20251 4 sword_hearts[0]=0;
20252 4 sword_hearts[1]=5;
20253 4 sword_hearts[2]=12;
20254 4 sword_hearts[3]=21;
20255 4 }
20256
20257
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20258 {
20259 4 temp_zinit.last_map=0;
20260 4 temp_zinit.last_screen=0;
20261 4 }
20262
20263
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20264 {
20265 4 temp_zinit.max_magic=0;
20266 4 temp_zinit.magic=0;
20267
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20268 4 }
20269
20270
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20271 {
20272
20273
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20274 {
20275 16 beam_hearts[x]=100;
20276 16 }
20277
20278
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20279 {
20280
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20281
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_qr(qr_LENSHINTS+i,0);
20282 16 }
20283
20284
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20285 {
20286
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20287 16 }
20288
20289
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_HIDECARRIEDITEMS,0);
20290 4 hookshot_links=100;
20291 4 temp_zinit.msg_more_x=224;
20292 4 temp_zinit.msg_more_y=64;
20293 4 }
20294
20295 // Okay, let's put these legacy values into itemsbuf.
20296
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 15)
20297
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4096 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
20298 {
20299
11/11
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 3936 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
4096 switch(i)
20300 {
20301 case iFairyStill:
20302 16 itemsbuf[i].misc1 = stationary_fairy_hearts;
20303 16 itemsbuf[i].misc2 = stationary_fairy_magic;
20304 16 itemsbuf[i].misc3 = 0;
20305 16 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20306 16 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20307 16 break;
20308
20309 case iFairyMoving:
20310 16 itemsbuf[i].misc1 = moving_fairy_hearts;
20311 16 itemsbuf[i].misc2 = moving_fairy_magic;
20312 16 itemsbuf[i].misc3 = 50;
20313 16 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20314 16 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20315 16 break;
20316
20317 case iRPotion:
20318 16 itemsbuf[i].misc1 = red_potion_hearts;
20319 16 itemsbuf[i].misc2 = red_potion_magic;
20320 16 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20321 16 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20322 16 break;
20323
20324 case iBPotion:
20325 16 itemsbuf[i].misc1 = blue_potion_hearts;
20326 16 itemsbuf[i].misc2 = blue_potion_magic;
20327 16 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20328 16 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20329 16 break;
20330
20331 case iSword:
20332 16 itemsbuf[i].pickup_hearts = sword_hearts[0];
20333 16 itemsbuf[i].misc1 = beam_hearts[0];
20334 16 itemsbuf[i].misc2 = beam_power[0];
20335 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20336
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20337 16 break;
20338
20339 case iWSword:
20340 16 itemsbuf[i].pickup_hearts = sword_hearts[1];
20341 16 itemsbuf[i].misc1 = beam_hearts[1];
20342 16 itemsbuf[i].misc2 = beam_power[1];
20343
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20344 16 break;
20345
20346 case iMSword:
20347 16 itemsbuf[i].pickup_hearts = sword_hearts[2];
20348 16 itemsbuf[i].misc1 = beam_hearts[2];
20349 16 itemsbuf[i].misc2 = beam_power[2];
20350
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20351 16 break;
20352
20353 case iXSword:
20354 16 itemsbuf[i].pickup_hearts = sword_hearts[3];
20355 16 itemsbuf[i].misc1 = beam_hearts[3];
20356 16 itemsbuf[i].misc2 = beam_power[3];
20357
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20358 16 break;
20359
20360 case iHookshot:
20361 16 itemsbuf[i].misc1 = hookshot_length;
20362 16 itemsbuf[i].misc2 = hookshot_links;
20363 16 break;
20364
20365 case iLongshot:
20366 16 itemsbuf[i].misc1 = longshot_length;
20367 16 itemsbuf[i].misc2 = longshot_links;
20368 16 break;
20369 }
20370 4112 }
20371
20372
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20373 {
20374 //was new subscreen rule
20375
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_qr(qr_FREEFORM)?1:0;
20376
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_FREEFORM,0);
20377 4 }
20378
20379
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20380 {
20381 4 temp_zinit.start_dmap=0;
20382 4 }
20383
20384
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20385 {
20386
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20387 4 }
20388
20389
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
129 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20390 {
20391 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20392 temp_zinit.max_rupees=999;
20393 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20394 }
20395
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20396 {
20397 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20398 temp_zinit.max_bombs = 8;
20399 }
20400 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20401 //time to ensure that we port all new values properly:
20402
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(Header->zelda_version < 0x250)
20403 {
20404
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20405 16 }
20406
20407
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 21)
20408 {
20409
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.hp_per_heart,f))
20410 {
20411 return qe_invalid;
20412 }
20413
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.magic_per_block,f))
20414 {
20415 return qe_invalid;
20416 }
20417
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20418 {
20419 return qe_invalid;
20420 }
20421
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20422 {
20423 return qe_invalid;
20424 }
20425 36 }
20426 else
20427 {
20428 93 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20429 93 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20430 93 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20431 93 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20432 }
20433
20434
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 22)
20435 {
20436
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 36 times.
936 for(int32_t q = 0; q < 25; ++q)
20437 {
20438
2/4
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 900 times.
900 if(!p_igetw(&temp_zinit.scrcnt[q],f))
20439 {
20440 return qe_invalid;
20441 }
20442 900 }
20443
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 36 times.
936 for(int32_t q = 0; q < 25; ++q)
20444 {
20445
2/4
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 900 times.
900 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f))
20446 {
20447 return qe_invalid;
20448 }
20449 900 }
20450 36 }
20451 else
20452 {
20453
2/2
✓ Branch 0 taken 2325 times.
✓ Branch 1 taken 93 times.
2418 for(int32_t q = 0; q < 25; ++q)
20454 {
20455 2325 temp_zinit.scrcnt[q] = 0;
20456 2325 temp_zinit.scrmaxcnt[q] = 0;
20457 2325 }
20458 }
20459
20460
20461
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 23)
20462 {
20463
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_type,f))
20464 {
20465 return qe_invalid;
20466 }
20467
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_arg,f))
20468 {
20469 return qe_invalid;
20470 }
20471
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_percent,f))
20472 {
20473 return qe_invalid;
20474 }
20475
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.def_lightrad,f))
20476 {
20477 return qe_invalid;
20478 }
20479
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.transdark_percent,f))
20480 {
20481 return qe_invalid;
20482 }
20483 36 }
20484 else
20485 {
20486 93 temp_zinit.dither_type = 0;
20487 93 temp_zinit.dither_arg = 0;
20488 93 temp_zinit.dither_percent = 20;
20489 93 temp_zinit.def_lightrad = 24;
20490 93 temp_zinit.transdark_percent = 0;
20491 }
20492
20493
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 24)
20494 {
20495
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.darkcol,f))
20496 {
20497 return qe_invalid;
20498 }
20499 36 }
20500 else
20501 {
20502 93 temp_zinit.darkcol = BLACK;
20503 }
20504
20505
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 25)
20506 {
20507
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.gravity2,f))
20508 {
20509 return qe_invalid;
20510 }
20511
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.swimgravity,f))
20512 {
20513 return qe_invalid;
20514 }
20515 36 }
20516 else
20517 {
20518 93 temp_zinit.gravity2 = temp_zinit.gravity*100;
20519 93 temp_zinit.swimgravity = 5;
20520 }
20521
20522
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 26)
20523 {
20524
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20525 {
20526 return qe_invalid;
20527 }
20528
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20529 {
20530 return qe_invalid;
20531 }
20532
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20533 {
20534 return qe_invalid;
20535 }
20536 36 }
20537 else
20538 {
20539 93 temp_zinit.heroSideswimUpStep = 150;
20540 93 temp_zinit.heroSideswimSideStep = 100;
20541 93 temp_zinit.heroSideswimDownStep = 75;
20542 }
20543
20544
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 27)
20545 {
20546
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20547 {
20548 return qe_invalid;
20549 }
20550 36 }
20551 else
20552 {
20553 93 temp_zinit.exitWaterJump = 0;
20554 }
20555
20556
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 29)
20557 {
20558
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20559 {
20560 return qe_invalid;
20561 }
20562 36 }
20563 else
20564 {
20565 93 temp_zinit.bunny_ltm = 0;
20566 }
20567
20568
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 30)
20569 {
20570
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.switchhookstyle,f))
20571 {
20572 return qe_invalid;
20573 }
20574 36 }
20575 else
20576 {
20577 93 temp_zinit.switchhookstyle = 1;
20578 }
20579
20580
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 31)
20581 {
20582
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.magicdrainrate,f))
20583 {
20584 return qe_invalid;
20585 }
20586 36 }
20587 else
20588 {
20589
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20590
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20591 }
20592
20593
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 temp_zinit.clear_genscript();
20594
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(s_version > 32)
20595 {
20596 34 word numgenscript = 0;
20597
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
34 if(!p_igetw(&numgenscript,f))
20598 return qe_invalid;
20599
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20600 return qe_invalid;
20601
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 for(auto q = 1; q < numgenscript; ++q)
20602 {
20603 if(!p_getc(&padding,f))
20604 return qe_invalid;
20605 if(!(padding&2))
20606 continue;
20607 temp_zinit.gen_doscript[q] = padding&1;
20608 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20609 return qe_invalid;
20610 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20611 return qe_invalid;
20612 for(auto p = 0; p < 8; ++p)
20613 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20614 return qe_invalid;
20615 if(!p_igetl(&temp_zinit.gen_dataSize[q],f))
20616 return qe_invalid;
20617 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f))
20618 return qe_invalid;
20619 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20620 return qe_invalid;
20621 }
20622 34 }
20623
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 97 times.
129 if(s_version > 33)
20624 {
20625
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20626 return qe_invalid;
20627
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 if(!p_getc(&temp_zinit.hero_swim_div,f))
20628 return qe_invalid;
20629 32 }
20630
20631
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 zinit = temp_zinit;
20632
20633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(zinit.heroAnimationStyle==las_zelda3slow)
20634 {
20635 hero_animation_speed=2;
20636 }
20637 else
20638 {
20639 129 hero_animation_speed=1;
20640 }
20641
20642 129 return 0;
20643 441 }
20644
20645 /*
20646 void setupitemdropsets()
20647 {
20648 for(int32_t i=0; i<isMAX; i++)
20649 {
20650 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20651 }
20652 }
20653 */
20654
20655 117 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20656 {
20657 117 build=build; // here to prevent compiler warnings
20658 dword dummy_dword;
20659 117 word item_drop_sets_to_read=0;
20660 item_drop_object tempitemdrop;
20661 117 word s_version=0, s_cversion=0;
20662
20663
2/2
✓ Branch 0 taken 29952 times.
✓ Branch 1 taken 117 times.
30069 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20664 {
20665 29952 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20666 29952 }
20667
20668
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 4 times.
117 if(version > 0x192)
20669 {
20670 113 item_drop_sets_to_read=0;
20671
20672 //section version info
20673
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_version,f))
20674 {
20675 return qe_invalid;
20676 }
20677
20678 113 FFCore.quest_format[vItemDropsets] = s_version;
20679
20680 //al_trace("Item drop sets version %d\n", s_version);
20681
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
20682 {
20683 return qe_invalid;
20684 }
20685
20686 //section size
20687
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy_dword,f))
20688 {
20689 return qe_invalid;
20690 }
20691
20692 //finally... section data
20693
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&item_drop_sets_to_read,f))
20694 {
20695 return qe_invalid;
20696 }
20697
20698
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
20699 {
20700 return qe_invalid;
20701 }
20702 113 }
20703 else
20704 {
20705 4 init_item_drop_sets();
20706 }
20707
20708
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 113 times.
117 if(s_version>=1)
20709 {
20710
2/2
✓ Branch 0 taken 2055 times.
✓ Branch 1 taken 113 times.
2168 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20711 {
20712
1/2
✓ Branch 0 taken 2055 times.
✗ Branch 1 not taken.
2055 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f))
20713 {
20714 return qe_invalid;
20715 }
20716
20717
2/2
✓ Branch 0 taken 20550 times.
✓ Branch 1 taken 2055 times.
22605 for(int32_t j=0; j<10; ++j)
20718 {
20719
1/2
✓ Branch 0 taken 20550 times.
✗ Branch 1 not taken.
20550 if(!p_igetw(&tempitemdrop.item[j],f))
20720 {
20721 return qe_invalid;
20722 }
20723 20550 }
20724
20725
2/2
✓ Branch 0 taken 22605 times.
✓ Branch 1 taken 2055 times.
24660 for(int32_t j=0; j<11; ++j)
20726 {
20727
1/2
✓ Branch 0 taken 22605 times.
✗ Branch 1 not taken.
22605 if(!p_igetw(&tempitemdrop.chance[j],f))
20728 {
20729 return qe_invalid;
20730 }
20731 22605 }
20732
20733 // Dec 2008: Addition of the 'Tall Grass' set, #12,
20734 // overrides the quest's set #12.
20735
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2055 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2055 if(s_version<2 && i==12)
20736 continue;
20737
20738 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
20739
1/4
✓ Branch 0 taken 2055 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2055 if(s_version<2) for(int32_t j=0; j<10; ++j)
20740 {
20741 int32_t it = tempitemdrop.item[j];
20742
20743 if((itemsbuf[it].family == itype_rupee
20744 && ((itemsbuf[it].amount)&0xFFF) == 10)
20745 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
20746 {
20747 tempitemdrop.chance[j+1]=0;
20748 }
20749 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
20750 {
20751 tempitemdrop.chance[j+1]=0;
20752 }
20753
20754 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
20755 if(itemsbuf[it].family == itype_misc)
20756 {
20757 // If a non-gameplay item was selected, then item drop was aborted.
20758 // Reflect this by increasing the 'Nothing' chance accordingly.
20759 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
20760 tempitemdrop.chance[j+1]=0;
20761 }
20762 }
20763
20764 2055 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
20765 2055 }
20766 113 }
20767
20768 117 return 0;
20769 117 }
20770
20771 113 int32_t readfavorites(PACKFILE *f, int32_t, word)
20772 {
20773 int32_t temp_num;
20774 dword dummy_dword;
20775 word num_favorite_combos;
20776 word num_favorite_combo_aliases;
20777 113 word s_version=0, s_cversion=0;
20778
20779 //section version info
20780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
20781 {
20782 return qe_invalid;
20783 }
20784
20785 113 FFCore.quest_format[vFavourites] = s_version;
20786
20787
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
20788 {
20789 return qe_invalid;
20790 }
20791
20792 //section size
20793
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy_dword,f))
20794 {
20795 return qe_invalid;
20796 }
20797
20798 113 word per_row = FAVORITECOMBO_PER_ROW;
20799
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 32 times.
113 if(s_version >= 3)
20800
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&per_row,f))
20801 return qe_invalid;
20802 //finally... section data
20803
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&num_favorite_combos,f))
20804 {
20805 return qe_invalid;
20806 }
20807
20808 //Hack; port old favorite combos
20809
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
113 if(s_version < 3 && num_favorite_combos == 100)
20810 81 per_row = 13;
20811
20812
2/2
✓ Branch 0 taken 33900 times.
✓ Branch 1 taken 113 times.
34013 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
20813 33900 favorite_combos[q] = -1;
20814
2/2
✓ Branch 0 taken 33900 times.
✓ Branch 1 taken 113 times.
34013 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
20815 33900 favorite_comboaliases[q] = -1;
20816
2/2
✓ Branch 0 taken 8636 times.
✓ Branch 1 taken 113 times.
8749 for(int32_t i=0; i<num_favorite_combos; i++)
20817 {
20818
1/2
✓ Branch 0 taken 8636 times.
✗ Branch 1 not taken.
8636 if(!p_igetl(&temp_num,f))
20819 {
20820 return qe_invalid;
20821 }
20822
20823
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 8100 times.
8636 if(per_row == FAVORITECOMBO_PER_ROW)
20824 536 favorite_combos[i]=temp_num;
20825 else
20826 {
20827 8100 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
20828 8100 favorite_combos[new_i]=temp_num;
20829 }
20830 8636 }
20831
20832
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&num_favorite_combo_aliases,f))
20833 {
20834 return qe_invalid;
20835 }
20836
20837
2/2
✓ Branch 0 taken 8100 times.
✓ Branch 1 taken 113 times.
8213 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
20838 {
20839
1/2
✓ Branch 0 taken 8100 times.
✗ Branch 1 not taken.
8100 if(!p_igetl(&temp_num,f))
20840 {
20841 return qe_invalid;
20842 }
20843
20844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8100 times.
8100 if(per_row == FAVORITECOMBO_PER_ROW)
20845 favorite_comboaliases[i]=temp_num;
20846 else
20847 {
20848 8100 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
20849 8100 favorite_comboaliases[new_i]=temp_num;
20850 }
20851 8100 }
20852
20853 113 word max_combo_cols = 0;
20854 113 word max_mappages = 0;
20855
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 32 times.
113 if(s_version >= 2)
20856 {
20857
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&max_combo_cols,f))
20858 return qe_invalid;
20859 32 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
20860
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 32 times.
160 for(int q = 0; q < max_combo_cols; ++q)
20861 {
20862
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetl(&tmp,f))
20863 return qe_invalid;
20864
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetl(&tmp2,f))
20865 return qe_invalid;
20866
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetl(&tmp3,f))
20867 return qe_invalid;
20868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(q < MAX_COMBO_COLS)
20869 {
20870 128 First[q] = tmp;
20871 128 combo_alistpos[q] = tmp2;
20872 128 combo_pool_listpos[q] = tmp3;
20873 128 }
20874 128 }
20875
20876
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&max_mappages,f))
20877 return qe_invalid;
20878
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 32 times.
320 for(int q = 0; q < max_mappages; ++q)
20879 {
20880
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(!p_igetl(&tmp,f))
20881 return qe_invalid;
20882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(!p_igetl(&tmp2,f))
20883 return qe_invalid;
20884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(q < MAX_MAPPAGE_BTNS)
20885 {
20886 288 map_page[q].map = tmp;
20887 288 map_page[q].screen = tmp2;
20888 288 }
20889 288 }
20890 32 }
20891
20892
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 113 times.
437 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
20893 {
20894 324 First[q] = 0;
20895 324 combo_alistpos[q] = 0;
20896 324 combo_pool_listpos[q] = 0;
20897 324 }
20898
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 113 times.
842 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
20899 {
20900 729 map_page[q].map = 0;
20901 729 map_page[q].screen = 0;
20902 729 }
20903
20904 113 return 0;
20905 113 }
20906
20907 /*
20908 switch (ret) {
20909 case 0:
20910 break;
20911
20912 case qe_invalid:
20913 goto invalid;
20914 break;
20915 default:
20916 pack_fclose(f);
20917 if(!oldquest)
20918 delete_file(tmpfilename);
20919 return ret;
20920 break;
20921 }
20922 */
20923
20924 const char *skip_text[skip_max]=
20925 {
20926 "skip_header", "skip_rules", "skip_strings", "skip_misc",
20927 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
20928 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
20929 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
20930 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
20931 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
20932 "skip_favorites"
20933 };
20934
20935
20936 void port250QuestRules(){
20937
20938 portCandleRules(); //Candle
20939 portBombRules();
20940
20941 }
20942
20943 void portCandleRules()
20944 {
20945 bool hurtshero = get_qr(qr_FIREPROOFHERO);
20946 //itemdata itemsbuf;
20947 for ( int32_t q = 0; q < MAXITEMS; q++ )
20948 {
20949 if ( itemsbuf[q].family == itype_candle )
20950 {
20951 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
20952 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
20953 }
20954 }
20955 }
20956
20957 void portBombRules()
20958 {
20959 bool hurtshero = get_qr(qr_OUCHBOMBS);
20960 //itemdata itemsbuf;
20961 for ( int32_t q = 0; q < MAXITEMS; q++ )
20962 {
20963 if ( itemsbuf[q].family == itype_bomb )
20964 {
20965 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
20966 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
20967 }
20968 }
20969 }
20970
20971 2892 static int section_id_to_enum(int id)
20972 {
20973
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 125 times.
✓ Branch 6 taken 113 times.
✓ Branch 7 taken 125 times.
✓ Branch 8 taken 125 times.
✓ Branch 9 taken 125 times.
✓ Branch 10 taken 125 times.
✓ Branch 11 taken 125 times.
✓ Branch 12 taken 125 times.
✓ Branch 13 taken 113 times.
✓ Branch 14 taken 113 times.
✓ Branch 15 taken 125 times.
✓ Branch 16 taken 125 times.
✓ Branch 17 taken 113 times.
✓ Branch 18 taken 113 times.
✓ Branch 19 taken 113 times.
✓ Branch 20 taken 113 times.
✓ Branch 21 taken 125 times.
✓ Branch 22 taken 125 times.
✓ Branch 23 taken 113 times.
✓ Branch 24 taken 113 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2892 switch (id)
20974 {
20975 case ID_HEADER: return skip_header;
20976 125 case ID_RULES: return skip_rules;
20977 125 case ID_STRINGS: return skip_strings;
20978 125 case ID_MISC: return skip_misc;
20979 125 case ID_TILES: return skip_tiles;
20980 125 case ID_COMBOS: return skip_combos;
20981 113 case ID_COMBOALIASES: return skip_comboaliases;
20982 125 case ID_CSETS: return skip_csets;
20983 125 case ID_MAPS: return skip_maps;
20984 125 case ID_DMAPS: return skip_dmaps;
20985 125 case ID_DOORS: return skip_doors;
20986 125 case ID_ITEMS: return skip_items;
20987 125 case ID_WEAPONS: return skip_weapons;
20988 113 case ID_COLORS: return skip_colors;
20989 113 case ID_ICONS: return skip_icons;
20990 125 case ID_INITDATA: return skip_initdata;
20991 125 case ID_GUYS: return skip_guys;
20992 113 case ID_HEROSPRITES: return skip_herosprites;
20993 113 case ID_SUBSCREEN: return skip_subscreens;
20994 113 case ID_FFSCRIPT: return skip_ffscript;
20995 113 case ID_SFX: return skip_sfx;
20996 125 case ID_MIDIS: return skip_midis;
20997 125 case ID_CHEATS: return skip_cheats;
20998 113 case ID_ITEMDROPSETS: return skip_itemdropsets;
20999 113 case ID_FAVORITES: return skip_favorites;
21000 case ID_ZINFO: return skip_zinfo;
21001 }
21002
21003 return -1;
21004 2892 }
21005
21006 2892 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21007 {
21008 2892 int section_enum = section_id_to_enum(section_id);
21009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2892 times.
2892 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2892 times.
2892 if (skip)
21011 {
21012 word s_version;
21013 if (!p_igetw(&s_version,f))
21014 {
21015 return qe_invalid;
21016 }
21017
21018 word c_version;
21019 if (!p_igetw(&c_version,f))
21020 {
21021 return qe_invalid;
21022 }
21023
21024 if (section_id == ID_RULES && s_version > 16)
21025 {
21026 dword dummy;
21027 if (!p_igetl(&dummy,f))
21028 {
21029 return qe_invalid;
21030 }
21031 }
21032
21033 if (section_id == ID_FFSCRIPT && s_version >= 18)
21034 {
21035 word dummy;
21036 if (!p_igetw(&dummy,f))
21037 {
21038 return qe_invalid;
21039 }
21040 }
21041
21042 dword section_length;
21043 if (!p_igetl(&section_length,f))
21044 {
21045 return qe_invalid;
21046 }
21047
21048 if (pack_fseek(f, section_length))
21049 {
21050 return qe_invalid;
21051 }
21052
21053 if (!pack_feof(f))
21054 {
21055 if (!p_mgetl(&section_id,f))
21056 {
21057 return qe_invalid;
21058 }
21059 }
21060
21061 return qe_cancel;
21062 }
21063
21064 2892 return qe_OK;
21065 2892 }
21066
21067 //Internal function for loadquest wrapper
21068 129 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, const byte *skip_flags, byte printmetadata)
21069 {
21070 129 DMapEditorLastMaptileUsed = 0;
21071 129 combosread=false;
21072 129 mapsread=false;
21073 129 fixffcs=false;
21074
21075 // show_progress=true;
21076 char tmpfilename[L_tmpnam];
21077 129 temp_name(tmpfilename);
21078 // char percent_done[30];
21079 129 bool catchup=false;
21080 byte tempbyte;
21081 129 word old_map_count=map_count;
21082
21083 129 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21084 129 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21085 129 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21086
21087
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_rules))
21088 {
21089 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21090 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21091 }
21092
21093 129 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21094 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21095
21096
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_midis))
21097 {
21098 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21099 }
21100
21101
21102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_ffscript))
21103 {
21104 129 zScript.clear();
21105 129 globalmap.clear();
21106 129 genericmap.clear();
21107 129 ffcmap.clear();
21108 129 itemmap.clear();
21109 129 npcmap.clear();
21110 129 ewpnmap.clear();
21111 129 lwpnmap.clear();
21112 129 playermap.clear();
21113 129 dmapmap.clear();
21114 129 screenmap.clear();
21115 129 itemspritemap.clear();
21116 129 comboscriptmap.clear();
21117 129 subscreenmap.clear();
21118
21119
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21120 {
21121 65919 ffcmap[i].clear();
21122 65919 }
21123
21124 129 globalmap[0].slotname = "Slot 1:";
21125 129 globalmap[0].scriptname = "~Init";
21126 129 globalmap[0].update();
21127
21128
2/2
✓ Branch 0 taken 903 times.
✓ Branch 1 taken 129 times.
1032 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21129 {
21130 903 globalmap[i].clear();
21131 903 }
21132
21133
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21134 {
21135 32895 itemmap[i].clear();
21136 32895 }
21137
21138 //new script types -- prevent carrying over to a quest that you load after reading them
21139 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21140
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21141 {
21142 32895 npcmap[i].clear();
21143 32895 }
21144
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21145 {
21146 32895 lwpnmap[i].clear();
21147 32895 }
21148
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21149 {
21150 32895 ewpnmap[i].clear();
21151 32895 }
21152
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 129 times.
645 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21153 {
21154 516 playermap[i].clear();
21155 516 }
21156
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21157 {
21158 32895 dmapmap[i].clear();
21159 32895 }
21160
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21161 {
21162 32895 screenmap[i].clear();
21163 32895 }
21164
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21165 {
21166 32895 itemspritemap[i].clear();
21167 32895 }
21168
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21169 {
21170 65919 comboscriptmap[i].clear();
21171 65919 }
21172
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21173 {
21174 65919 genericmap[i].clear();
21175 65919 }
21176
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21177 {
21178 32895 subscreenmap[i].clear();
21179 32895 }
21180
21181 129 reset_scripts();
21182 129 }
21183
21184 zquestheader tempheader;
21185 129 memset(&tempheader, 0, sizeof(zquestheader));
21186 129 zinfo tempzi;
21187 129 tempzi.clear();
21188 129 load_tmp_zi = &tempzi;
21189
21190 // oldquest flag is set when an unencrypted qst file is suspected.
21191 129 bool oldquest = false;
21192 129 int32_t open_error=0;
21193 129 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21194
21195
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (!f)
21196 {
21197 ASSERT(open_error != 0);
21198 return open_error;
21199 }
21200 char zinfofilename[2048];
21201 129 replace_extension(zinfofilename, filename, "zinfo", 2047);
21202 129 int32_t ret=0;
21203
21204 //header
21205 129 box_out("Reading Header...");
21206 129 ret=readheader(f, &tempheader, printmetadata);
21207
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
129 checkstatus(ret);
21208 129 box_out("okay.");
21209 129 box_eol();
21210
21211
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if(read_zinfo)
21212 {
21213 36 box_out("Reading ZInfo - ");
21214
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
36 box_out(read_ext_zinfo ? "External..." : "Internal...");
21215
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
36 if(read_ext_zinfo)
21216 {
21217 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21218 1 ret=readzinfo(inf, tempzi, tempheader);
21219
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21220
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21221 1 }
21222 else
21223 {
21224 35 ret=readzinfo(f, tempzi, tempheader);
21225
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
35 checkstatus(ret);
21226 }
21227 36 box_out("okay.");
21228 36 box_eol();
21229 36 }
21230
21231
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(tempheader.zelda_version>=0x193)
21232 {
21233 dword section_id;
21234
21235 //section id
21236
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_mgetl(&section_id,f))
21237 {
21238 return qe_invalid;
21239 }
21240
21241 125 std::set<dword> seen_sections;
21242
21243
3/4
✓ Branch 0 taken 3017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✓ Branch 3 taken 125 times.
3017 while(!pack_feof(f))
21244 {
21245
2/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✗ Branch 3 not taken.
2892 if (seen_sections.contains(section_id))
21246 return qe_invalid;
21247
1/2
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
2892 seen_sections.insert(section_id);
21248
21249
2/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✗ Branch 3 not taken.
2892 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21250 {
21251 if (retval == qe_cancel)
21252 continue;
21253 checkstatus(retval);
21254 }
21255
21256
24/25
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 113 times.
✓ Branch 6 taken 125 times.
✓ Branch 7 taken 125 times.
✓ Branch 8 taken 125 times.
✓ Branch 9 taken 125 times.
✓ Branch 10 taken 125 times.
✓ Branch 11 taken 125 times.
✓ Branch 12 taken 113 times.
✓ Branch 13 taken 113 times.
✓ Branch 14 taken 125 times.
✓ Branch 15 taken 125 times.
✓ Branch 16 taken 113 times.
✓ Branch 17 taken 113 times.
✓ Branch 18 taken 113 times.
✓ Branch 19 taken 113 times.
✓ Branch 20 taken 125 times.
✓ Branch 21 taken 125 times.
✓ Branch 22 taken 113 times.
✓ Branch 23 taken 113 times.
✗ Branch 24 not taken.
2892 switch(section_id)
21257 {
21258 case ID_RULES:
21259
21260 //rules
21261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21262 {
21263 box_out("found.");
21264 box_eol();
21265 catchup=false;
21266 }
21267
21268
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Rules...");
21269
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readrules(f, &tempheader);
21270
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21271
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21272
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21273 125 break;
21274
21275 case ID_STRINGS:
21276
21277 //strings
21278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21279 {
21280 box_out("found.");
21281 box_eol();
21282 catchup=false;
21283 }
21284
21285
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Strings...");
21286
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readstrings(f, &tempheader);
21287
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21288
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21289
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21290 125 break;
21291
21292 case ID_MISC:
21293
21294 //misc data
21295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21296 {
21297 box_out("found.");
21298 box_eol();
21299 catchup=false;
21300 }
21301
21302
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Misc. Data...");
21303
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readmisc(f, &tempheader, Misc);
21304
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21305
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21306
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21307 125 break;
21308
21309 case ID_TILES:
21310
21311 //tiles
21312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21313 {
21314 box_out("found.");
21315 box_eol();
21316 catchup=false;
21317 }
21318
21319
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Tiles...");
21320
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21321
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21322
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21323
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21324 125 break;
21325
21326 case ID_COMBOS:
21327
21328 //combos
21329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21330 {
21331 box_out("found.");
21332 box_eol();
21333 catchup=false;
21334 }
21335
21336
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Combos...");
21337
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21338 125 combosread=true;
21339
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21340
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21341
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21342 125 break;
21343
21344 case ID_COMBOALIASES:
21345
21346 //combo aliases
21347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21348 {
21349 box_out("found.");
21350 box_eol();
21351 catchup=false;
21352 }
21353
21354
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Combo Aliases...");
21355
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21356
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21357
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21358
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21359 113 break;
21360
21361 case ID_CSETS:
21362
21363 //color data
21364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21365 {
21366 box_out("found.");
21367 box_eol();
21368 catchup=false;
21369 }
21370
21371
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Color Data...");
21372
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21373
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21374
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21375
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21376 125 break;
21377
21378 case ID_MAPS:
21379
21380 //maps
21381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21382 {
21383 box_out("found.");
21384 box_eol();
21385 catchup=false;
21386 }
21387
21388
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Maps...");
21389
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readmaps(f, &tempheader);
21390 125 mapsread=true;
21391
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21392
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21393
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21394 125 break;
21395
21396 case ID_DMAPS:
21397
21398 //dmaps
21399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21400 {
21401 box_out("found.");
21402 box_eol();
21403 catchup=false;
21404 }
21405
21406
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading DMaps...");
21407
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21408
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21409
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21410
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21411 125 break;
21412
21413 case ID_DOORS:
21414
21415 //door combo sets
21416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21417 {
21418 box_out("found.");
21419 box_eol();
21420 catchup=false;
21421 }
21422
21423
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Doors...");
21424
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readdoorcombosets(f, &tempheader);
21425
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21426
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21427
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21428 125 break;
21429
21430 case ID_ITEMS:
21431
21432 //items
21433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21434 {
21435 box_out("found.");
21436 box_eol();
21437 catchup=false;
21438 }
21439
21440
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Items...");
21441
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21442
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21443
21444
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21445
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21446 125 break;
21447
21448 case ID_WEAPONS:
21449
21450 //weapons
21451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21452 {
21453 box_out("found.");
21454 box_eol();
21455 catchup=false;
21456 }
21457
21458
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Weapons...");
21459
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readweapons(f, &tempheader);
21460
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21461
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21462
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21463 125 break;
21464
21465 case ID_COLORS:
21466
21467 //misc. colors
21468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21469 {
21470 box_out("found.");
21471 box_eol();
21472 catchup=false;
21473 }
21474
21475
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Misc. Colors...");
21476
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readmisccolors(f, &tempheader, Misc);
21477
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21478
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21479
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21480 113 break;
21481
21482 case ID_ICONS:
21483
21484 //game icons
21485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21486 {
21487 box_out("found.");
21488 box_eol();
21489 catchup=false;
21490 }
21491
21492
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Game Icons...");
21493
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readgameicons(f, &tempheader, Misc);
21494
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21495
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21496
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21497 113 break;
21498
21499 case ID_INITDATA:
21500
21501 //initialization data
21502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21503 {
21504 box_out("found.");
21505 box_eol();
21506 catchup=false;
21507 }
21508
21509
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Init. Data...");
21510
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readinitdata(f, &tempheader);
21511
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21512
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21513
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21514
21515
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_subscreens))
21516 {
21517
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 98 times.
125 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21518 {
21519
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 setupsubscreens();
21520
21521
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 27 times.
13851 for(int32_t i=0; i<MAXDMAPS; ++i)
21522 {
21523 13824 int32_t type=DMaps[i].type&dmfTYPE;
21524
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 13617 times.
13824 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21525
1/2
✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
13824 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21526 13824 }
21527 27 }
21528 125 }
21529
21530
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_sfx))
21531 {
21532 125 setupsfx();
21533 125 }
21534
21535
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!get_bit(skip_flags, skip_itemdropsets))
21536 {
21537
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 init_item_drop_sets();
21538 125 }
21539
21540
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_favorites))
21541 {
21542 125 init_favorites();
21543 125 }
21544
21545 125 break;
21546
21547 case ID_GUYS:
21548
21549 //guys
21550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21551 {
21552 box_out("found.");
21553 box_eol();
21554 catchup=false;
21555 }
21556
21557
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Custom Guy Data...");
21558
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readguys(f, &tempheader);
21559
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21560
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21561
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21562 125 break;
21563
21564 case ID_HEROSPRITES:
21565
21566 //player sprites
21567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21568 {
21569 box_out("found.");
21570 box_eol();
21571 catchup=false;
21572 }
21573
21574
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Custom Player Sprite Data...");
21575
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readherosprites(f, &tempheader);
21576
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21577
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21578
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21579 113 break;
21580
21581 case ID_SUBSCREEN:
21582
21583 //custom subscreens
21584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21585 {
21586 box_out("found.");
21587 box_eol();
21588 catchup=false;
21589 }
21590
21591
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Custom Subscreen Data...");
21592
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readsubscreens(f);
21593
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21594
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21595
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21596 113 break;
21597
21598 case ID_FFSCRIPT:
21599
21600 //Freeform combo scripts
21601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21602 {
21603 box_out("found.");
21604 box_eol();
21605 catchup=false;
21606 }
21607
21608
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading FF Script Data...");
21609
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readffscript(f, &tempheader);
21610
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21611
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21612
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21613 113 break;
21614
21615 case ID_SFX:
21616
21617 //SFX data
21618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21619 {
21620 box_out("found.");
21621 box_eol();
21622 catchup=false;
21623 }
21624
21625
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading SFX Data...");
21626
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readsfx(f, &tempheader);
21627
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21628
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21629
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21630 113 break;
21631
21632 case ID_MIDIS:
21633
21634 //midis
21635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21636 {
21637 box_out("found.");
21638 box_eol();
21639 catchup=false;
21640 }
21641
21642
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Tunes...");
21643
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readtunes(f, &tempheader, tunes);
21644
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21645
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21646
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21647 125 break;
21648
21649 case ID_CHEATS:
21650
21651 //cheat codes
21652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21653 {
21654 box_out("found.");
21655 box_eol();
21656 catchup=false;
21657 }
21658
21659
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Cheat Codes...");
21660
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcheatcodes(f, &tempheader);
21661
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21662
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21663
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21664 125 break;
21665
21666 case ID_ITEMDROPSETS:
21667
21668 //item drop sets
21669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21670 {
21671 box_out("found.");
21672 box_eol();
21673 catchup=false;
21674 }
21675
21676
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Item Drop Sets...");
21677
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
21678
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21679
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21680
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21681 113 break;
21682
21683 case ID_FAVORITES:
21684
21685 //favorite combos and combo aliases
21686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21687 {
21688 box_out("found.");
21689 box_eol();
21690 catchup=false;
21691 }
21692
21693
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Favorite Combos...");
21694
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
21695
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21696
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21697
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21698 113 break;
21699
21700 default:
21701 if(!catchup)
21702 {
21703 box_out("Bad token! Searching...");
21704 box_eol();
21705 }
21706
21707 catchup=true;
21708 break;
21709 }
21710
21711
21712
1/2
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
2892 if(catchup)
21713 {
21714 //section id
21715 section_id=(section_id<<8);
21716
21717 if(!p_getc(&tempbyte,f))
21718 {
21719 return qe_invalid;
21720 }
21721
21722 section_id+=tempbyte;
21723 }
21724
21725 else
21726 {
21727 //section id
21728
3/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 125 times.
2892 if(!pack_feof(f))
21729 {
21730
2/4
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2767 times.
✗ Branch 3 not taken.
2767 if(!p_mgetl(&section_id,f))
21731 {
21732 return qe_invalid;
21733 }
21734 2767 }
21735 }
21736 }
21737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 }
21738 else
21739 {
21740
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
21741
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
21742
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
21743
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
21744
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
21745
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
21746
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
21747
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
21748
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
21749
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
21750
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
21751
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
21752
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
21753
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
21754
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
21755
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
21756
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
21757
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
21758 };
21759
21760
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 68 times.
140 for (auto& [desc, section_id, fn] : hardcoded_sections)
21761 {
21762 // Would be nice, but old sections mostly did not save section sizes. We could advance by
21763 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
21764 // read all the sections even if requested to skip some.
21765 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21766 // {
21767 // if (retval == qe_cancel)
21768 // continue;
21769 // checkstatus(retval);
21770 // }
21771
21772
3/6
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
136 box_out(fmt::format("Reading {}...", desc).c_str());
21773
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ret = fn();
21774
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
68 checkstatus(ret);
21775
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_out("okay.");
21776
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_eol();
21777 }
21778
21779
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!get_bit(skip_flags, skip_subscreens))
21780 {
21781
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setupsubscreens();
21782
21783
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
21784 {
21785 2048 int32_t type=DMaps[i].type&dmfTYPE;
21786
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21787
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21788 2048 }
21789 4 }
21790
21791
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("Setting Up Default Sound Effects...");
21792
21793
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_sfx))
21794 4 setupsfx();
21795
21796
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("okay.");
21797
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_eol();
21798
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 }
21799
21800 129 init_spritelists();
21801
21802 // check data
21803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(f)
21804 {
21805 129 pack_fclose(f);
21806 129 }
21807 129 clear_quest_tmpfile();
21808
21809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!oldquest)
21810 {
21811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(exists(tmpfilename))
21812 {
21813 delete_file(tmpfilename);
21814 }
21815 129 }
21816
21817
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if(fixffcs && combosread && mapsread)
21818 {
21819 for(int32_t i=0; i<map_count; i++)
21820 {
21821 for(int32_t j=0; j<MAPSCRS; j++)
21822 {
21823 for(int32_t m=0; m<32; m++)
21824 {
21825 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
21826 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
21827 }
21828 }
21829 }
21830 }
21831
21832
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 29 times.
129 if(get_qr(qr_CONTFULL_DEP))
21833 {
21834 29 set_qr(qr_CONTFULL_DEP, 0);
21835 29 set_bit(zinit.misc, idM_CONTPERCENT, 1);
21836 29 zinit.cont_heart=100;
21837 29 zinit.start_heart=zinit.hc;
21838 29 }
21839
21840 129 box_out("Done.");
21841 129 box_eol();
21842 129 box_end(false);
21843
21844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_header))
21845 {
21846 129 memcpy(Header, &tempheader, sizeof(tempheader));
21847 129 }
21848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_zinfo))
21849 {
21850 129 ZI.copyFrom(tempzi);
21851 129 }
21852
21853
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_maps))
21854 {
21855 map_count=old_map_count;
21856 }
21857
21858
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_rules))
21859 {
21860 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
21861 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
21862 }
21863
21864
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_midis))
21865 {
21866 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
21867 }
21868
21869 //Debug FFCore.quest_format[]
21870 129 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
21871 129 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
21872 129 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
21873 129 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
21874 129 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
21875 129 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
21876 129 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
21877 129 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
21878 129 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
21879 129 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
21880 129 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
21881 129 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
21882 129 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
21883 129 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
21884 129 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
21885 129 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
21886 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
21887 129 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
21888 129 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
21889 129 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
21890 129 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
21891 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
21892 129 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
21893 129 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
21894 129 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
21895 129 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
21896 129 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
21897 129 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
21898 129 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
21899 129 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
21900 //Print metadata for versions under 2.10 here. Bleah.
21901
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if( FFCore.quest_format[vZelda] < 0x210 )
21902 {
21903 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
21904
21905
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
21906 {
21907 case 0x193:
21908 {
21909 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
21910 }
21911 case 0x192:
21912 {
21913 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
21914 }
21915 case 0x190:
21916 {
21917 4 zprint2("Last saved in ZC Editor Version: 1.90");
21918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21919 4 else zprint2("\n");
21920 4 break;
21921 }
21922 case 0x188:
21923 {
21924 zprint2("Last saved in ZC Editor Version: 1.88");
21925 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21926 else zprint2("\n");
21927 break;
21928 }
21929 case 0x187:
21930 {
21931 zprint2("Last saved in ZC Editor Version: 1.87");
21932 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21933 else zprint2("\n");
21934 break;
21935 }
21936 case 0x186:
21937 {
21938 zprint2("Last saved in ZC Editor Version: 1.86");
21939 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21940 else zprint2("\n");
21941 break;
21942 }
21943 case 0x185:
21944 {
21945 zprint2("Last saved in ZC Editor Version: 1.85");
21946 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21947 else zprint2("\n");
21948 break;
21949 }
21950 case 0x184:
21951 {
21952 zprint2("Last saved in ZC Editor Version: 1.84");
21953 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21954 else zprint2("\n");
21955 break;
21956 }
21957 case 0x183:
21958 {
21959 zprint2("Last saved in ZC Editor Version: 1.83");
21960 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21961 else zprint2("\n");
21962 break;
21963 }
21964 case 0x182:
21965 {
21966 zprint2("Last saved in ZC Editor Version: 1.82");
21967 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21968 else zprint2("\n");
21969 break;
21970 }
21971 case 0x181:
21972 {
21973 zprint2("Last saved in ZC Editor Version: 1.81");
21974 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21975 else zprint2("\n");
21976 break;
21977 }
21978 case 0x180:
21979 {
21980 zprint2("Last saved in ZC Editor Version: 1.80");
21981 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
21982 else zprint2("\n");
21983 break;
21984 }
21985 default:
21986 {
21987 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
21988 }
21989 }
21990 4 }
21991
21992 129 return qe_OK;
21993
21994 invalid:
21995 box_out("error.");
21996 box_eol();
21997 box_end(true);
21998
21999 if(f)
22000 {
22001 pack_fclose(f);
22002 }
22003
22004 if(!oldquest)
22005 {
22006 if(exists(tmpfilename))
22007 {
22008 delete_file(tmpfilename);
22009 }
22010 }
22011
22012 return qe_invalid;
22013
22014 129 }
22015
22016 129 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22017 {
22018 129 const char* basename = get_filename(filename);
22019 129 zapp_reporting_add_breadcrumb("load_quest", basename);
22020 129 zapp_reporting_set_tag("qst.filename", basename);
22021
22022 129 loading_qst_name = filename;
22023 129 loading_qst_num = qst_num;
22024 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22025 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22026
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (!is_ci())
22027 loadquest_report = report;
22028 129 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22029 129 load_tmp_zi = NULL;
22030 129 loading_qst_name = NULL;
22031 129 loadquest_report = false;
22032 129 loading_qst_num = 0;
22033
22034 129 zapp_reporting_set_tag("qst.title", Header->title);
22035 129 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22036
22037 129 return ret;
22038 }
22039